1
votes

I have developed an iPhone app which I am trying to port to iPad using UISplitViewController. The iPhone app is an ideal candidate for "Master-detail view" design. The master view shows a list of things and clicking on each row opens up its detail in the detail view. However, my problem is that I need the detail view to contain a static table containing 5 cells. I am unable to figure out how to put a static table in the detail view of the UISplitViewController. I tried the following:

  1. Created a master-detail storyboard
  2. Set up the detail view controller's class as a custom class derived from UITableViewController. This is the same class which I am using in my iPhone code for the main screen.
  3. Dragged a table view in the detail view
  4. Configured the detail view to show static cells

As soon as I change the cells to static, I get an error "Static table views are only valid when embedded in UITableViewController instances".

I am unable to understand what this error means and how to configure static cells in detail view. What should I do?

I am relatively new to iOS programming and have been struggling for past 2 days on this problem.

1
I knew, I heard it... check it, may help...Mitiay Okhotnikov

1 Answers

0
votes

The error means that in order to use static cells, you have to have a UITableViewController. It is not enough to use a UIViewController and add a UITableView to it. What I would do is to add a container view to my detail, and embed a UITableViewController in it (ctrl+drag - embed segue), that way the UITableViewController becomes childViewController of your detail VC and you can change it when you tap a different cell in the master.

If you don't want to change it, then just delete the detail part suggested by the storyboard, and add an instance of UITableViewController.

Edit:

Here is my setup that I just tried, and it works. The right most screen in the picture is a subclass of UITableViewController. When you add a Container view to your detail, it adds a UIViewController automatically. Delete that and add a UITableViewController.

enter image description here