The question of how to add a place holder view to an empty UITableView seems to be very common. There also seem to be many different solutions.
These place-holder views can be seem in a range of applications including the iOS AppStore when it doesn’t have a data connection.

The Problem

Currently, as of iOS 5.0, there is no build in way of presenting a custom view when a table view is empty.
The way I envisaged my solution working was as a drop in replacement for UITableView (a subclass of). This could then call the appropriate data source method to retrieve the UIView to be overlayed.

The Solution

My first step was to extend the UITableViewDataSource protocol to add our own method for obtaining a UIView to be displayed as the placeholder.

The next step was to determine when the table view has been updated in order to re-evaluate whether the placeholder view should be displayed. So, I created a subclass of UITableView overriding some of the methods involved in updating the displayed state of the table view. Within these over-ridden methods we call the super class’ method but also call a method which checks with the data source for the contents of the table view, and displays the placeholder if appropriate.

Below is are the overridden methods (_batchUpdateInProgress is a member of the subclass)

To determine if the placeholder needs to be displayed, we first check to see if the table view is being edited (if it is, we won’t display the placeholder), and then query the table views data source methods to determine if there is any data being displayed.
If we should be showings the place holder, we call the extending protocol method on the data source, to get the UIView to be displayed, and animate it’s appearance. If the placeholder shouldn’t be displayed, and it currently is, we will animate it’s disappearance.