0

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.

Eugene Trapeznikov
  • 3,220
  • 6
  • 47
  • 74

1 Answers1

1

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];

}
sergio
  • 68,819
  • 11
  • 102
  • 123