1

I am trying to change the grey gradient background on an embedded UITableView to the color I have set on the parent view in the Storyboard.

I have been looking around, and found the following threads:

I have an IBOutlet in the parent controller connecting the two views.

My implementation looks as follows:

- (void)viewDidLoad {
    [super viewDidLoad];
    [activeShipmentsTable setBackgroundView:nil];
    [activeShipmentsTable setBackgroundView:[[[UIView alloc] init] autorelease]];
    [activeShipmentsTable setBackgroundColor:UIColor.clearColor];
}

What am I doing wrong?

Thanks.

Community
  • 1
  • 1

1 Answers1

3

Try setting et the background color on the table's background view, not the table itself.

UIView *view = [[[UIView alloc] init] autorelease];
view.backgroundColor = [UIColor redColor];
self.tableView.backgroundView = view;
Christian Schnorr
  • 10,489
  • 8
  • 45
  • 81
  • Thanks! I got this to work! I also found out that it does not matter wether the code snippet is inserted into loadView or viewDidLoad. Do you know what best pratice is? –  Jan 22 '12 at 17:43
  • I, personally use -loadView only for creating the main view. Any other subviews get added in -viewDidLoad and get removed in -viewDidUnload. – Christian Schnorr Jan 22 '12 at 18:04