Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.
Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.
Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.
Please create a new report for Bug 60739 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.
If the latest results still closely match this report, you can use the original description:
In special cases on GitHub you might also want the comments: GitHub Markdown with public comments
Created attachment 25748 [details] TabbedPage example project with a few WriteLine statements added I’m working with an XF app that features a TabbedPage and have noticed an important difference in the order that events are called between iOS and Android. The event in question is TabbedPage.CurrentPageChanged. On iOS, the CurrentPageChanged event is handled before any overridden OnAppearing() or OnDisappearing() methods of the ContentPage are called. On Android however, that order is reversed; the CurrentPageChanged event is handled AFTER any OnAppearing() or OnDisappearing() methods of the ContentPage are called. This is a big deal for me, because I’m trying to reliably know, in the ContentPage, when the user has left the tab that this contentPage lives on so I can do some operations as they leave. I’ve confirmed the behavior using one of the Xamarin sample apps and a few Debug.WriteLine statements. I'll attach it here, but it's based off of this: https://developer.xamarin.com/samples/xamarin-forms/Navigation/TabbedPage This is the output of the sample app that illustrates the issue. This output shows what happens when I'm on the Schedule tab and tap on the Settings tab. iOS: MainPage.CurrentPageChanged event handled SchedulePage.OnDisappearing() called SettingsPage.OnAppearing() called Android: SchedulePage.OnDisappearing() called SettingsPage.OnAppearing() called MainPage.CurrentPageChanged event handled Latest XF version tested: 2.5.0.91635
To be clear, the way that iOS does it is what I want
Hi Tom, Yes, these differences are something we want to either unify across platforms, or at least provide a more clear way to get the events to control the order you need to handle them per platform. The iOS UITabBarController + UIViewController and Android ViewPager + Fragment clearly don't see eye to eye here. You could as a workaround create your own renderers for those pages and surface the events you need. You'll find some helpers from the community on GitHub such as https://github.com/TheEightBot/Xamarin.Forms-Lifecycle-Aware-View We have in our backlog to do a revision of these, and I'll make sure to reflect your notes in our spec. https://forums.xamarin.com/discussion/85747/xamarin-forms-feature-roadmap/p1 You may want to also join the conversation here: https://forums.xamarin.com/discussion/84510/improved-life-cycle-support#latest That proposal has been in spirit accepted, but needs a spec and someone to take on the work and generate a pull request. I'm marking this ticket as an enhancement.
Cool, thanks David. I appreciate the quick response!