Pushing a Navigation Controller Is Not Supported

Pushing a navigation controller is not supported- performing segues

I've tried this and have no problems, its all done in IB with no additional code required ...

  1. Start a new project, "Single View Application" using story boards
  2. Select storyboard and delete the views its produced.
  3. Drag on a new Navigation Controller (it will bring a table view with it)
  4. Delete the table and the table view controller, so you are just left with the Navigation Controller
  5. Drag on a normal view controller
  6. Right Click and drag from the Navigation controller to the new View and choose "Relationship - Root View Controller"
  7. Drag a "Bar Button Item" on to the Navbar which should be visible on the top of your ViewController, you can rename this Forward if you wish.
  8. Now drag on another view controller which is the one your "Forward" button will push in to view.
  9. Right Click and drag from the bar button to the 2nd View Controller, and choose "Push"

Run the project and you will get a Single view with a Navbar and your button, clicking your button will Push the other view and give you a Back Button to return to the first View Controller. I'll try and post a picture of my storyboard if it helps.

PushViewControllers

Plasma

Pushing a navigation controller is not supported error message

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

How to Push a Navigation Controller after instantiate

Set your tableVC as root view controller of navigation controller :

let appdelegate = UIApplication.sharedApplication().delegate as! AppDelegate
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
var tableViewController = mainStoryboard.instantiateViewControllerWithIdentifier("TableViewController") as! HomeViewController
let navigationVC = UINavigationController(rootViewController: tableViewController)
appdelegate.window!.rootViewController = navigationVC

Now in TableViewController ,to hide navigation bar

    self.navigationController?.setNavigationBarHidden(true, animated: false)

Then you can push another view controller like you mentioned

let newViewController = storyboard!.instantiateViewController(withIdentifier: "player") as! UINavigationController
self.navigationController?.pushViewController(newViewController, animated: true)


Related Topics



Leave a reply



Submit