Adding a subview under my UITableView

I am experimenting with programmatically adding a subview under my UITableView. I'm using the swirl map sample from Eric Sadoun's book to check if the view below my UITableView is actually the view I'm adding. However, when the UITableView is curled up, the view color in the below view is white, not the black view I add in the code below. Any idea what I am doing wrong to insert a 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];

      

It was also confirmed that my top level view only has 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>
   )

      

+1


source to share


1 answer


You are trying to insert a Subview: belowSubview: with a view that is returned to itself. If you are trying to insert a BELOW subcategory into a table, you need to send the table with the caption:



[self.tableView.superview insertSubview: pickerView belowSubview: self.tableView];

      

+9


source







All Articles