user3295976
user3295976

Reputation: 1

Adding ViewController to existing UINavigation stack

How to present modal ViewController on top of UINavigationController without using initWithRootViewController, just with adding it to the existing navigationcontroller stack?

my code is:

TableViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"TableView"];
UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:controller];
[self presentViewController:navi animated:NO completion:nil];

edit: what i actually want is to do like: "vc1 push vc2 modal vc3" and than use "poptoroot...to vc1". But the initWithRootViewController (vc3) is ruining it.

Upvotes: 0

Views: 71

Answers (1)

Samkit Jain
Samkit Jain

Reputation: 2533

If you want to change the stack of navigationController. Use :

- (void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated NS_AVAILABLE_IOS(3_0); // If animated is YES, then simulate a push or pop depending on whether the new top view controller was previously in the stack.

It will help.

Upvotes: 1

Related Questions