Harish Saran Harish Saran - 14 days ago 7
iOS Question

UINavigationController and back button action

I have an two

controllers
1st is
self
and 2nd is
maincontroller
, where I'm pushing
maincontroller
in stack, so the back button is automatically coming.

Here I need to make an alert when the user presses the back button.

How can I do this?

Answer

Or you can use the UINavigationController's delegate methods. The method willShowViewController is called when the back button of your VC is pressed.

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated;