0

i am new to IOS development.i want to ask a question which has basically two parts, but let me explain the scenario i am facing.

i have 4 ViewControllers A,B,C,D and each of them have UiNavigation bar with default (back) button. D have an extra UIButton (NO).

Now when i press (NO) on D it push B. [self.navigationController pushViewController:B animated:NO]; Now what i want is if i press (back) on B, UINavigation Controller should not bring me back to D but instead of D ,it should push A. But if B was pushed from D by touching (back) on D, then it should continue its default behavior and navigate to the view which is on stack top.

So basically my question consist of two parts.

1) how to know the parent ViewController(the one which pushed the current ViewController).

2)how to override the default action of (back) button.

Please correct me if i am doing something wrong. and let me know to handle this scenario in a better way.

Thanks in advance. :)

  • 1
    For your two parts: 1. you can store the view that pushed the current view in NSUserDefaults. 2. This might help : http://stackoverflow.com/questions/5085452/override-back-button-in-navigation-stack – R3D3vil Sep 10 '14 at 18:27
  • Welcome to Stack Overflow! Here, you should really split your questions up into single questions. It would also help to show what code you've already tried. – DanM7 Sep 10 '14 at 18:29

0 Answers0