Josh Kahane
Josh Kahane

Reputation: 17159

What methods are called when returning to UINavigationController's root view?

What methods are called when returning to a previous view, or the root view, of a UINavigationController?

Also, when the user taps the back button to return to the previous view, is everything in the view that's disappearing released, and its values unretrievable from the parent view?

Upvotes: 0

Views: 2185

Answers (3)

beryllium
beryllium

Reputation: 29767

UINavigationController also has two delegate method. Maybe they would help you:

navigationController:willShowViewController:animated: navigationController:didShowViewController:animated:

Upvotes: 2

Felipe Cypriano
Felipe Cypriano

Reputation: 2737

You can use the viewWillAppear, viewDidAppear, viewWillDisappear and viewDidDisappear in your view controllers. This works independently of UINavigationController.

Upvotes: 2

jrturton
jrturton

Reputation: 119242

viewWillDisappear:animated: will be called on a view controller before it is popped from the navigation stack.

This is the place to do anything that you need to do when the user goes "back" in the navigation controller. You can access any other controllers in the navigation stack via self.navigationController.viewControllers which is an array of all the view controllers currently in the stack, with the root view controller at index 0.

Upvotes: 2

Related Questions