Pushing a navigation controller is not supported e

2019-06-26 11:02发布

问题:

I am working on an app where the user has the possibility to add products and those products are then displayed in a TableView. I created a TableViewController with static cells and two sections and I want to hook the cell in the second section with another TableViewController.

I dragged the TableViewController from the object library, embedded it in a navigation controller and made a push segue from the cell to the NavigationController but when I try to run the app I get the following error message in the output window:

2013-03-20 09:55:32.981 STAM[725:c07] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported' First throw call stack: (0x1d04012 0x11e8e7e 0x22a5b0 0x22a098 0x585da3 0x577ad9 0x577b54 0x1df899 0x1dfb3d 0xbe6e83 0x1cc3376 0x1cc2e06 0x1caaa82 0x1ca9f44 0x1ca9e1b 0x1f3c7e3 0x1f3c668 0x13065c 0x2a6d 0x2995) libc++abi.dylib: terminate called throwing an exception

Here's a screenshot form my storyboard.

Thank you very much!

Granit

回答1:

Your UINavigationController is at the wrong place. It should be before the UITableViewController.

You can select the UITableViewController from story board then from menu: Editor > Embed In > Navigation Controller.

You can get more info about the navigation stack from the reference guide.

http://developer.apple.com/library/ios/#documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html