0

I have a navigation controller in my application. Now I am having a viewcontroller, where the back-button of the navigation-bar should not go to the previous viewcontroller. I want that if someone press this back-button, my first viewcontroller (MainMenu) is called. Is it possible to do this without using a BarButtonItem?

Example: VC1 = MainMenu -> VC2 -> VC3

Now if I press the back-button of VC3, I want to go to VC1!!!! (normally I get back to VC2)=

4
  • what? do u want to goto previous screen? use [self.navigationController popViewControllerAnimated:YES];
    – iAhmed
    Aug 4, 2014 at 10:46
  • look add my post. Hope now you can understand :)
    – basti12354
    Aug 4, 2014 at 10:55
  • The button will call an action method and you can do whatever you like in that action method.
    – Droppy
    Aug 4, 2014 at 10:55
  • Check this stackoverflow.com/questions/18824186/…
    – Kumar KL
    Aug 4, 2014 at 10:57

1 Answer 1

0

UINavigationController has a property called viewControllers of type NSArray. After pushing the third one, your navigation controller's viewControllers has 3 VC's (VC1, VC2, VC3). You can make a new array containing VC1 and VC3, and set it to the viewControllers property. That way the previous VC in the stack will be VC1 and after pressing the back button you will go to VC1, not VC2.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.