How to manipulate Navigation Controller?

200 views Asked by At

I'm just starting to learn xcode and wondered, how do I reverse the flow of Navigation Controller? I have 1 TableViewController and 1 ViewController, and I want the ViewController to appear first. Please help.

Instead of:

NavigationController >>> TableViewController >>> ViewController

I want it like this:

NavigationController >>> ViewController >>> TableViewController and back to ViewController
2

There are 2 answers

4
Ashutosh On

If your view hierarchy in storyboard is as: a:UITableViewController(A) embedded with UINavigationController. b:Now UIViewController(B) is comming from UITableViewController(A).

  1. You can change the order of A and B as embeed UINavigationController from B instead of embedding it from A and now call A from B ie. Take UIViewController, then embeed UINavigationController in it and now add UITableViewController to be pushed from UIViewConrtroller.
0
user1316121 On

To show the UITableViewController instance and skip UIViewController instance:

[self.navigationController setViewControllers:@[myViewController, myTableViewController] animated:YES];

To pop to UIViewController instance and skip UITableViewController instance:

[self.navigationController setViewControllers:@[myViewController] animated:YES];