I’m trying to insert a view behind the cells of a uitableview but I can’t find a way to do it properly. Everytime I add a subview to self.view or self.tableview, it goes on the foreground, even if I use the method “sendSubviewToBack:” …
Do someone have an idea on how to achieve it ?
PS : I don’t want to use self.tableview.backgroundView because the view is fixed.
Thanks
What you experience is logical. The
self.viewof aUITableViewis indeed the table view. If you insert a subview, it is inserted on top of the table view – and there is no way to send it to the back.Solution 1
The most flexible solution is to switch to a
UIViewConntrollerand implement the table view behaviour yourself. You need to@property. This is now a subview ofself.view. You can do this in code or in IB.<UITableViewDelegate>and<UITableViewDatasource>protocolsdelegateanddatasourceproperties of the table view toselfSolution 2
If you just want to display something behind the tableView you might be able to use the table view property
backgroundView. This will display behind the cells, but you will have limited control over the view’s size (which you could again solve with further subviews of the background view). Also, you need to make sure your cells are transparent.