I have an existing ios5/xcode 4.2 app, and I want a button to open a view that will display a list of items, and have a back button and an add new button.
I thought I could achieve this by adding a button to the main view controller, then dragging in to the storyboard a new UITableViewController, then embed a UINavigationController (editor->Embed In->Navigation Controller).
Then i right clicked on the button, dragged it to the navigation controller, and thought, ok this should work.
However, there is no back button, and xcode will not let me drag one in, nor will it allow me to drag in the button bar item “[+]” for the link to add new.
When I run the app, the list shows, of course I have no way to go back to the view controller with the button on it.
What am i doing wrong? – thanks.
(my question is similar to this
but for xcode 4.2)
Embed the main view controller, not the new one, in a
UINavigationController. This should add a simulatedUINavigationBarto the main view (if not, set one up under Simulated Metrics). At this point you should be able to drop in aUIBarButtonItemto the main view’s simulated bar.Next, draw a connection from your button to the new
UITableViewControllerto set up a push segue. At runtime, the back button will appear in the bar automatically.