iPhone: UiNavigationController back button [duplic

2019-03-31 11:37发布

问题:

Possible Duplicate:
How to tell when back button is pressed in a UINavigationControllerStack

Hey guys when I press the back button, what Delegate method is called? Best Regards Carlos Vargas

回答1:

UINavigationBarDelegate is the delegate class and it implements -navigationBar:shouldPopItem, since these controllers work in stacks you're just pushing or popping views. This will most likely always evaluate to true otherwise I feel a back button that does anything but pop a view controller will violate Apple's Human Interface Guidelines.



回答2:

I agree with elsurudo, the - (void)viewWillDisappear also gets called when you go to a third ViewController, but maybe you want your connection to exist in the Third View Controller but not in the First View Controller. So you might want to detect when the user goes back from the Second View Controller so you can disconnect properly.