I have a small test app which just cycles between 3 pages. Here is AppDelegate:
public override bool FinishedLaunching (UIApplication app, NSDictionary optio
Avoid patterns like:
var navigationController = new UINavigationController(dialogViewController);
View.Add (navigationController.View);
because navigationController
won't be referenced (on the managed side) once the View.Add
call is done and the garbage collector can dispose it (whenever it wants). However from the native side it will be expected to exist. Calls going back (from native to managed) to the disposed instance will crash your application.
The right pattern is to declare navigationController
as a field (instead of a local variable) of your type and create/assign it in the method. This will keep a reference to navigationController
alive as long as the parent instance exists (and ensure any callback won't go to a disposed object).
E.g.
private UINavigationController navigationController;
...
public override void ViewDidLoad ()
{
...
var dialogViewController = new DialogViewController(rootElement);
navigationController = new UINavigationController(dialogViewController);
View.Add (navigationController.View);
...
}