Bug 34697 - Xamarin.Forms.Page.OnAppearing() called after ViewDidAppear on iOS
Summary: Xamarin.Forms.Page.OnAppearing() called after ViewDidAppear on iOS
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.5.0
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-10-08 15:05 UTC by Pablo Biagioli
Modified: 2016-04-13 18:36 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

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 on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Pablo Biagioli 2015-10-08 15:05:13 UTC
Hi, I wanted to make a custom CarouselPage with Circular/infinite scrolling to both sides. I discovered that in Android works fine, but in iOS I can't start displaying a middle positioned the page before showing the first page declared in Children by code (not XAML). This is, in my opinion, due to having the Xamarin.Forms.Page.SendAppearing after calling ViewDidAppear in iOS.

According to the Xamarin.Forms documentation for OnAppearing method:
When overriden, allows devs to customize the behavior immediately prior to the Page becoming visible.

The Result is that if I set the CurrentPage property within OnAppearing method, the CarouselPage swipes automatically to the page set as Current one.

SampleProject.CustomControls.CircularCarouselPage.OnAppearing ()
Xamarin.Forms.Page.SendAppearing () 
Xamarin.Forms.Platform.iOS.CarouselPageRenderer.ViewDidAppear (animated=false)
ObjCRuntime.Messaging.void_objc_msgSendSuper_bool () 
UIKit.UIViewController.ViewDidAppear (animated=false) in /Users/builder/data/lanes/2077/1d27ac2c/source/maccore/src/build/ios/native/UIKit/UIViewController.g.cs:1112
Xamarin.Forms.Platform.iOS.NavigationRenderer.ViewDidAppear (animated=false) in 
UIKit.UIApplication.UIApplicationMain () in 
UIKit.UIApplication.Main (args={string[0]}, principal=0x0, delegate=0x551694f0) in /Users/builder/data/lanes/2077/1d27ac2c/source/maccore/src/UIKit/UIApplication.cs:74
UIKit.UIApplication.Main (args={string[0]}, principalClassName=(null), delegateClassName="AppDelegate") in /Users/builder/data/lanes/2077/1d27ac2c/source/maccore/src/UIKit/UIApplication.cs:58
SampleProject.iOS.Application.Main (args={string[0]}) in /.../sample_project/SampleProject/SampleProject.iOS/Main.cs:19

The Xamarin.Forms version is the latest stable 1.5.0 release.

Best Regards
Comment 1 Rui Marinho 2015-11-18 11:56:07 UTC
This seems the normal behaviour can you attach a reproduction please?
Comment 2 Pablo Biagioli 2015-11-18 12:03:35 UTC
isn't the stacktrace enough?
Please read the whole stack trace above.

In Android OnAppearing happens BEFORE the View is displayed. This should be OK.
In iOS on the other hand, OnAppearing happens AFTER the View is displayed on the screen.

The Normal behavior is in your Xamarin.Forms documentation

Please provide a more human answer.

Comment 3 Jason Smith [MSFT] 2016-04-13 18:36:07 UTC
CarouselPage is being deprecated due to issues like this and replaced with CarouselView which should allow you to fix this. CarouselView is available in 2.2.0-pre1 and newer.