Is there any way I can catch the event when I press the back button in my iPhone application? Right now I am using a button with image named Back on it and defining the action for that.
My client requires default back button pointing to previous screen so based on click event I should be able make it point to particular screen so that title of that screen is shown.
In short i need back button to show the title i required, is it possible?
Thanks in advance.
There are two ways to do this:
Implement the back button yourself and call the
UINavigationController‘s- (UIViewController *)popViewControllerAnimated:(BOOL)animatedSubclass
UINavigationControllerand implement- (UIViewController *)popViewControllerAnimated:(BOOL)animatedto do your processing and pass on the call tosuper.As suggested in another answer
UINavigationBarDelegateallows you to detect whether the button has been pressed if you handle the– navigationBar:didPopItem:message.