UINavigationController ViewDidDisappear not firing for view

Question!

I'm using MonoTouch. When I push a new controller onto the stack of a UINavigationController, it works fine. When I hit the back button, NO events fire, even though visually, the view is popped off the stack. Specifically, I want to use ViewDidDisappear and ViewDidAppear to do some stuff:

SurveyEditor editor = new SurveyEditor(surveyInstance);
NavigationController.PushViewController(editor, true);

then in SurveyEditor:

public override void ViewWillDisappear (bool animated)
{
  Console.WriteLine("SurveyEditor ViewWillDisappear");
  base.ViewWillDisappear (animated);
}

public override void ViewDidDisappear (bool animated)
{
  Console.WriteLine("SurveyEditor ViewDidDisappear");
  base.ViewDidDisappear (animated);
}

None of these are being called, and in my root view, ViewDidAppear is also not getting called! Starting to lose my mind on this one.

By : whitehawk


Answers

If you launch the nav controller from the view Controller using the following, it does get called:

[self presentModalViewController:navigationController animated:YES];

(sorry this is not MonoTouch - I encountered the problem in the regular Objective-C. This was my solution.)

Look at Dustin Clark's comment here.

By : nont


Call it yourself, if it's not getting called. There's nothing magic happening about it, it's just a method on that ViewController. Let it know it's about to disappear.

By : Dan Ray


It turns out that if I have a navigation controller inside a ViewController, these events do not fire.

By : whitehawk


This video can help you solving your question :)
By: admin