Search code examples
iosuinavigationcontrolleruitableview

pushViewController without navigationcontroller


I have a class that is of type UITableViewController. This class has a member of type UINavigationBar that I use for adding in an edit button for the table view.

Using this method calling is invalid.

[self.navigationController pushViewController:controller];

How can I push a detail view onto the view after selecting a table row without wrapping my UITableViewController in a UINavigationController?


Solution

  • You can't push a view controller onto a navigation controller if there is no navigation controller. If you are wanting to be pushing controllers and have it display the topmost controller and everything, just use a UINavigationController and be done with it.

    You can push arbitrary UINavigationItems onto your UINavigationBar, and your bar's delegate will be notified when the user uses the back button so you can take appropriate action. See the documentation for more information.