Static Table View Containers

Static table views are the most straight forward way of laying out a list of items using Storyboards in Interface Builder. (You are using Storyboards by now right?) These type of table views are better suited for a static list of items like a menu or settings screen inside of your app. One of the limitations with this type of table view cell is that it requires a UITableViewController inside of your storyboard. This could be problematic because of how table view controllers intrinsically take over an entire screen worth of content.

An approach to get around this limitation is to use view controller containment within your storyboard. By doing this, you are essentially defining a content area for which your table view controller will be placed. Using a container gives the ability to layout your static cells alongside your parent view controller.

Start by dragging a container view onto your view controller where you want your table view to appear. Go ahead and delete the new ViewController that gets created and instead place a UITableViewController in your storyboard. Now control + drag in Interface Builder from your container view onto the new UITablVeiwController and click on the embed option.


If you do this correctly, your tableview will take on the dimensions of your container view giving you a good idea of its layout in relation to other views on the screen.


Now you have the flexibility of adding cells at design time without the need for boilerplate datasource logic associated with prototype cells.

Learn more about static table views from the WWDC session.

Show Comments