views:

362

answers:

1

I'm adding an image subview to an UITableViewController with a grouped table. Once I add the image subview I can see the table headers on top of the image, but the cells are being drawn behind the image.

Is there something else I need to do to ensure that the table cells appear on top of the background image? Here is the code I'm using in the UITableViewControlle's viewDidLoad:

CGRect myImageRect = CGRectMake(0.0f, 0.0f, 320.0f, 959.0f); 
UIImageView *backImageView = [[UIImageView alloc] initWithFrame:myImageRect]; 
[backImageView setImage:[UIImage imageNamed:@"somebackground.png"]]; 
[self.view addSubview:backImageView];
[self.view sendSubviewToBack:backImageView];
[backImageView release];

I realize that as an alternative I could simply create a composite view and drop the tableview on top of it rather than what I am trying to do here. If there isn't any other solution I will do so, but would prefer to use the approach I'm trying if at all possible.

A: 

It appears that the UITableView will often rearrange the zorder of views when refreshing. So, you need to manually manage resetting the zorder on any table events such as inserting/deleting/updating rows.

Harkonian