views:

145

answers:

1

UITableViewController seems to always hijack the View link in IB. So, if I put UITableView in a UIView and link up the View to that UIView, it still doesn't work. Only the UITableView is shown.

What I'd like to do is use a UITableViewController and put some labels on top of the uiTableView that can be hidden.. Like loading.. and No results found.

The only solution I have come up with is to resort to using UIViewController and then adding a UITableView link to the class and link it up in IB.

Am I missing something here?

+1  A: 

It's fine to use a UIViewController, make it implement the table view datasource and delegate protocols, and then hook a UITableView up to it. It's also fine to have the controller's main view be a container UIView, and have a UITableView as a subview of that.

And yes, this is probably the best way to add some kind of overlay view, such as a message label. So I think you're on the right track.

You should also be able to do this using a UITableViewController, instead of a UIViewController that explicitly implements the table view protocols. I've had success with this. I'm not sure what you mean when you say that UITableViewController "hijacks" the view outlet in IB.

It really isn't a big deal either way. UITableViewController doesn't do much other than implement those protocols, provide a different default loadView method, and call [tableView reloadData] by default on viewWillAppear:. If you do those things yourself, you'll be fine.

jasoncrawford
By "hijack" he means that the UITableViewController assumes that the table will occupy the entire view.
TechZen
I would add that you don't have to put the table's datasource and delegate methods in a view controller. They work find as standalone objects. This technique is especially useful if you need the same table in different views.
TechZen
OK, maybe I misunderstood. When he said "labels on top of the view", I thought he meant overlays. If all you want is a label above the view, at the top of the screen, all you need is to set the `tableHeaderView`.
jasoncrawford