Rectangle 27 0

ios Putting a UIView in front of UITableView in a UITableVewController?


Scene
  ViewController
    Top Layout Guide
    Bottom Layout Guide
    View
      Table View
      View  // the view which covers the table view.

Amazing. I was working under the impression that the first view in the list was in the front. It is the other way around. Thanks!

It sounds like you've accidentally put the cover view inside the table or behind it or something.

One of my apps does exactly this successfully. The UIView needs to be a peer of the UITableView (i.e. inside the same parent view) and in front of it (after it in the list of the parent's subviews).

Use constraints to make the table a fixed size relative to its superview, and to make the cover view the same size as the table and aligned with it, so it always covers it when visible.

Note
Rectangle 27 0

ios Putting a UIView in front of UITableView in a UITableVewController?


Found a solution specifically if you are using a UITableView Controller. If your data set is empty, use this code: [self.tableView setSeparatorInset:UIEdgeInsetsZero];. This removes the appearance of empty rows and makes your UITableView look like an empty UIView. Then, simply customize your view to make it how you want it. For my app, I added a label as a subview to the UITableView (if the data set was empty) giving my "no items" message.

Note
Rectangle 27 0

ios Putting a UIView in front of UITableView in a UITableVewController?


  • Create a prototype UITableViewCell that displays the "No Items" message you want the user to see.
  • Use a regular UIViewController with a UITableView added to it. That way, you can add the UIView (or maybe UILabel) to the UIViewController's view. Then, when you have no items to display, you can set the alpha of the UITableView to zero, and the label can be seen.
Note