Shared publicly  - 
 
iOS Static Table View Cells Error in Storyboards: The Solution -

When you are working Storyboards in XCode 4.2 (or higher,) there is a great new feature that allows you to create static table view cells. What this means is that you can layout the contents of your cells right there in the storyboard and not have to go through the steps of generating those cells from a UITableViewDatasource.

However...

In order to use static table view cells, your UITableView must be inside a UITableViewController. That's fine and dandy, but you may run into a problem if you set your base View Controller to a custom View Controller that inherits from UITableViewController. In such a scenario you will end up with an error in your build that says:

Illegal Configuration: Static table views are only valid when embedded in UITableViewController instances.

But, wait, didn't you just set your View Controller to a subclass of UITableViewController? Well, of course you did, but XCode doesn't seem to be smart enough to realize this. Try as you might to clean and re-clean and re-build your build, but you will never get rid of this error message.

The Fix:

It's simple really. You just have to let XCode know what it should have already figured out. Right-click your storyboard file and "Open As -> Source Code." Find the declaration for your View Controller, and you'll notice it is defined by an element that reads:

<viewController ...>
...
</viewController>

All you need to do is change that to:

<tableViewController ...>
...
</tableViewController>

Now, your project will build without a problem (assuming you've fixed all other problems in your build that is.) ;)
7
1
Igor Cherny's profile photoLogan Murray's profile photo
 
Thanks for the tip, this was very helpful. I did have to remove an intermediate UIView that somehow got between my table view and the controller, in case others are scratching their head.

I have a question though. I'm actually curious how Apple intends this to be used, since I can't understand putting a table view directly inside an instance of UITableViewController that isn't subclassed. Where would the logic for the screen go?
 
not working in xCode 5.1, after change source code I got error: The document "MainStoriboard.storyboard" could not be opened. Could not verify document content.
Add a comment...