views:

1099

answers:

3

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

+1  A: 

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.

Convolution
A: 

Also, if you properly push items on the stack then you never have to manually deal with the back button logic. If it does not work then you are doing something wrong. If you need to know when the user goes back and execute some code then you are doing it in the wrong place.

St3fan
This is not always the case. There are situations where you would like to run conditional code depending on whether the back button was pressed, and ONLY when the back button was pressed (ie. not is viewWillDisappear or something).
elsurudo
A: 

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.

Mark