Reputation: 50916
I'm experimenting with programmatically adding a subview below my UITableView. I'm using a map curl sample from Erica Sadun's book in order to test to see if the view below my UITableView is indeed the view I'm adding. However, when the UITableView curls up, the view color of the view below is white, not the black view I'm adding in the code below. Any idea what I'm doing wrong to insert my new view below the UITableView?
CGRect frame = [self.tableView frame];
NSLog(@"frame height: %f, frame width: %f", frame.size.height, frame.size.width);
NSLog(@"tableView origin: %f, %f", [self.tableView frame].origin.x, [self.tableView frame].origin.y);
NSLog(@"frame origin x: %f, y: %f", frame.origin.x, frame.origin.y);
UIView *pickerView = [[UIView alloc] initWithFrame:frame];
pickerView.backgroundColor = [UIColor blackColor];
pickerView.frame = frame;
pickerView.userInteractionEnabled = YES;
[self.tableView insertSubview:pickerView belowSubview:self.tableView];
Also my top level view has been confirmed to only have two views. Here's the output from [self.view subviews]
:
2008-12-23 20:44:20.923 MySample[11966:20b] subviews: (
<UITableView: 0x523ea0>,
<UINavigationBar: 0x528b10>
)
Upvotes: 1
Views: 8835
Reputation: 85542
You're trying to insertSubview:belowSubview: with the view being passed back to itself. If you're trying to insert a subview BELOW the table, you need to send the table's superview the message:
[self.tableView.superview insertSubview: pickerView belowSubview: self.tableView];
Upvotes: 9