I have a button that I have added to my navigation bar programatically. When I pressed this button, sometimes I want it to [self.navigationBar popViewControlleranimated:YES]
and sometimes I want it [self.navigationBar pushViewcontrollerAnimated:YES]
depending on some variables. I can get the popViewController
part to work, but I am unsure how to do the pushViewController
part. Mainly, where do I instantiate this viewController? As I understand it, it has to be part of the navigation controller already. But if I made this view in my story board, what do I connect it to to make it part of the navigation controller since my button is inserted programatically? Also, even if my button was not inserted programatically, and I instead added it via the story board, how would the case work when I want to popViewController
upon pressing the button? If I link the pushViewController
to this button, woudln't it try to push this view controller when I actually want to pop it? I suppose I could do and unanimated pop followed by an animated one, which might work.
Asked
Active
Viewed 251 times
0

bneely
- 9,083
- 4
- 38
- 46

user1529956
- 735
- 2
- 10
- 24
-
instead I'd suggest you to write format question properly.... – Preetam Jadakar Sep 21 '13 at 08:20
1 Answers
0
Simply connect the two nibs in your storyboard with a push segue( from the class of the one to the whole other):
and set it's identifier "something"
, then in your code replace push view controller with:
[self performSegueWithIdentifier:@"something" sender:self];

martin
- 1,007
- 2
- 16
- 32