Reputation: 22962
When pushing a viewcontroller using UINavigationController into the view:
We are having a hard time relying on wether those methods gets triggered or not.
Upvotes: 2
Views: 2536
Reputation: 17918
UINavigationController calls these methods directly on the controller that's being pushed when you call pushViewController:animated: Similarly, UITabBarController calls these methods directly when you switch tabs, and UIViewController calls them when you use presentModalViewController:animated:. They also get called when a view controller's view is added to a window. I've never seen these methods fail to get called in these specific contexts.
Now bear in mind that these methods only get called on the controller being pushed or presented in these specific contexts. These methods won't get called, for example, if you add your view controller's view as a subview of some view other than the UIWindow. Apple's documentation states that view controllers are intended only to be used with full screen views, which are typically presented using one of the methods described above. It's possible to ignore Apple's advice and associate a view controller with a subview of another view controller, but you'll have to delegate the viewWill/DidAppear/Disappear calls from the container view controller to the nested controller manually.
Upvotes: 6
Reputation: 3890
Check that you've got the function name exactly right, for example:
- (void)viewWillAppear:(BOOL)animated
For example, if you forget to declare the animated parameter, your function won't get called.
This may sound obvious, but I've made this mistake and since the original post doesn't have a code sample I thought I'd share!
Upvotes: 0