views:

226

answers:

1

I have a UITableViewController that is populated with some data. If the data comes back empty, obviously the table is empty. What is the appropriate method to use to handle this case and put up something like a UILabel with "No Data Available".

I have been using - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section but it's proven a bit cumbersome and I'm not longer confident it's the best place to do this.

+2  A: 

I'd probably reverse the philosophy a bit to only show the UITableView when content is available, and have the UIView show your 'no content' available image until the content is ready.

Once the content has been fetched and is ready to be presented - animate or create the UITableView into the view hierarchy over the 'no content' image and ask it to reload its data. This will have it start working through it's datasource delegate callbacks.

At least this way you won't have to worry about showing a tableview with no data, and mixing concerns with UITableViewDataSource callback methods.

crafterm
I like that. So I started with the Navigation Based app and ended up having a UITableViewController. So if I hide tableView, how do I add things to the view and what view is that underneith there? When I open up InterfaceBuilder I only see the tableview. It's confusing me.
Travis