views:

334

answers:

2

I have an iPhone project with a NIB that only has a table view (UITableViewController). My delegate loads the nib (and associated controller) and all is well. Now I'd like to have UILabel show up when there is no data to show in the table view. Revisiting the NIB it occurred to me that only the File's Owner, Delegate, and the Table View are present (i.e. no Window).

It seems like I've seen this before in apps when say you search for something and there are no results. What is the best practices approach to adding the UI label or any other UI element for that matter.

Thanks!

+1  A: 

You can just add a UILabel in interface builder over top of your table view and set it to hidden. Then, when you get 0 results, just call -setHidden:NO on the label.

You could as easily just return a single table row in the case where your results count is zero with some instructive text such as "No results" that is not tappable/selectable.

Matt Long
A: 

I'd go with Matt's answer. just make the label large and you can format it in Interface builder how you want it.

Makinitez21