Ipad – UITableView background color


I've seen various posts on background color for a UITableView for ios 4.2 but I just cannot seem to change the background color.

UIView *bgView = [[[UIView alloc] init] autorelease];
bgView.backgroundColor = [UIColor blackColor];
bgView.opaque = YES;
self.myTableView.backgroundView = bgView;

I've placed this code in a viewDidLoad but it won't change colors. My UITableView is an IBOutlet inside a UIViewController with a UITableViewDelegate & UITableViewDataSource so I'm thinking at the viewDidLoad the UITableView is already rendered and I cannot change its background color.

EDIT * – the UITableView is grouped

Best Solution

Try setting the background view of the table view to nil and also set the background colour of the table view

- (void)viewDidLoad
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.myTableView.backgroundView = nil;
    self.myTableView.backgroundColor = [UIColor blackColor];