How do I change the order of views displayed, when the two views I want to rearrange are not related?
I am trying to work on someone else's code, and they have a class which is a subclass of UITableViewController. I want to put a background in, so I put it as a subview of self.view .
The problem is, it's displayed in front of the table, and the table is located as self.tableView, not self.view.tableView . Since the two views aren't together, I can't use the sendSubviewToBack method.
self is the viewController class I'm working on.
Any ideas?
UIImageView *background = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"editInfoBG.png"]];
background.frame = CGRectMake(0, 0, 320, 416);
[self.view addSubview:background];
// Doesn't work, the table is not a subview of self.view
[self.view sendSubviewToBack:background];
If you want to add subviews into your viewcontroller, you should use a subclass of UIViewController
with manually added UITableView
as subview and implementing the UITableViewDataSource
and UITableViewDelegate
protocols instead of using UITableViewController
.