Navigation controller with static table cells?

I am trying to add a view that is a form containing 3 elements. These items will be inside a static grouped table. I need a navigation bar at the top using the "Save" and "Cancel" buttons. Both buttons should send the user back to the previous screen when pressed.

In the storyboard, I tried to create a navigation controller and then add a table to it, but I get the error message “Static table view is only valid when embedded in the UITableViewController”.

So, I tried creating a Table View Controller, but the storyboard will not allow me to place the navigation bar in one of them for some reason ...

What is the best way to do this?

+4
source share
2 answers

Add a UITableViewController to your storyboard, and then from the menu, choose Editor> Paste in the Navigation Panel Controller. This will close your table view controller in the controller of the navigation bar, and you can add your Save and Cancel buttons to the navigation bar.

It might seem a little wasteful to create a navigation controller with only one sub-controller to get the navigation bar, but this is an accepted way to do it.

+7
source

Oh ... this iOS stuff is hurting my head.

I wanted to do the same, have a TableView with a navigation bar at the top, but there was no menu item "Paste in .. Navigation bar", just "Paste in .. Navigation controller".

In the end, the solution to this was simpler than I thought.

I just needed to add a table view controller to my storyboard, then CTRL + drag Segue from the "calling" view controller onto my new table view controller, and voila, it immediately gives me a navigation bar.

0
source

All Articles