Background of detailViewController


#1

I cannot get the nice vertical line background one sees in the table view to display in the detailViewController. Here’s the code used in the book and implemented in my code.

-(void)viewDidLoad
{
    [super viewDidLoad];
    [[self view] setBackgroundColor:[UIColor groupTableViewBackgroundColor]];
}

#2

There are a couple other threads on this topic here.
I’m not sure if the groupTableViewBackgroundColor is deprecated or unused, but since the tableview background is a pinstripe pattern (on the iPhone), clearly it’s not just a simple color so a UIColor object isn’t going to work…

The general consensus is to just create a tableview, add it to your DetailViewController’s view and send it to the back so it’s not in the way:

- (void)viewDidLoad
{
    [super viewDidLoad];
    UITableView *tv = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
    [[self view] addSubview:tv];
    [[self view] sendSubviewToBack:tv];
}

Hope that helps


#3

Thanks, hbdesiato. I’ll give that a try.

Also, I did read that groupTableViewBackgroundColor was deprecated for 6.0.