Custom background of UITableView with grouped style

Question: I have an iPad project with iPhone SDK (Xcode) 4.1. The code must also run on iPhone 4. I cannot set the background of UITableView when the tableview style is “grouped”, not even with Interface Builder. It simply does not work:
[aTableView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"background.png"]]];
Answer: In your code you forgot to set backgroundView to nil. Put something like this into the loadView method:
    // IBOutlet UITableView *aTableView is set by Interface Builder
    if( self.aTableView ){
        [self.aTableView setBackgroundColor:[[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"Background.png"]]];
        self.aTableView.opaque = NO;    // It can be set in the IB
        self.aTableView.backgroundView = nil;
        self.view = self.aTableView;
    }else{
        NSLog(@"IB OUTLET is not set");
    }
In the IB you can create your own UIView with subviews of background image (UIImageView) and the table (UITableView). In this case you fully control all the visual elements and you can modify the view hierarchy there. If you want a more sophisticated one, you have to present a background image, draw cell borders and backgrounds… See Matt Coneybeare’s blog for such a solution here.