Eugene Trapeznikov
Eugene Trapeznikov

Reputation: 3240

Background image for UITableView on iPad

I got settings view in my iOS app which presented by UITableView. This app is universal, so you can run it on iPhone and on iPad. This table should be with custom background. And use this code for setting image for background:

table.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"settings_bg"]];

This is OK for iPhone:

enter image description here

But on iPad this background is grey!

enter image description here

Why? How should i set custom background for iPad? Thnx.

Upvotes: 0

Views: 487

Answers (1)

sergio
sergio

Reputation: 69027

This is somehow a known difference between iPhone and iPad UITableView behaviour in the grouped mode. Use this code instead (or similar):

if ([self.tableView respondsToSelector:@selector(backgroundView)]) {
    [self.tableView setBackgroundView:nil];
    UIView* bkgView = [[[UIView alloc] initWithFrame:self.tableView.bounds] autorelease];
    bkgView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:...]];
    [self.tableView setBackgroundView:bkgView];

}

Upvotes: 1

Related Questions