When/why/how would you use these methods?
- navigationController:willShowViewController:animated:
– navigationController:didShowViewController:animated:
Can't you just use these UIViewController Instance Methods instead?
– viewWillAppear:
– viewDidAppear:
– viewWillDisappear:
– viewDidDisappear:
You'd use the first ones if you want to be informed about these events outside the visible view controllers. The delegates allow you to get a notification at a single point. Using UIViewController
's methods bind you within these controllers, where you'd have to write/call same code multiple times to achieve the same.
Generally you'd divide tasks into these two groups:
The UINavigationControllerDelegate protocol defines methods a navigation controller delegate can implement to change the behavior when view controllers are pushed and popped from the stack of a navigation controller.
These method are important when you need to perform some actions that would not be on the scope of your view controller. the delegate it's supposed to be a object predecessor of your view controller on the hierarchy and that would be interested in perform some actions without the knowing of each view controller that is pushed or popped, these actions are not necessarily related with that view controller specifically, but they can be methods called on other objects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With