I need to set up a view that fills in the content area of a UITableView
, and that is displayed whenever that table view is empty, hidden otherwise. That view contains an image, a label, and a button to perform a simple action. I was hoping to achieve two things:
1) leverage the backgroundView
property of UITableView
, and
2) leverage the storyboard
as much as possible while minimizing the amount of code (maybe use a container view?).
However, I am not sure what is the best way to go about this. Insights appreciated, especially if you have already implemented this solution yourself.
You can probably do this a bunch of ways, but the easiest (conceptually) seems to be just use a container view that has two subviews:
UITableView
that is visible when it's not empty.UIView
that holds your image/label/button that is visible whenUITableView
is empty.Simply change their visibility depending on the content of the
UITableView
Even if you only use the
UITableView
and set it'sbackgroundView
to be theUIView
to display when theUITableView
is empty, virtually the same amount of work has to be done (you still have to create both views).