I am using iOS SDK 4.2. I have an UIPopoverController initialized with a navigation controller which is initializ开发者_运维问答ed with a view controller. One of the subviews of the view controller is a grouped table view. I would like to change the background color of the table view. However, if I do in the viewDidLoad method of the view controller
self.myTableView.backgroundColor = [UIColor blackColor];
the background does not changes, when the popover appears, the background of the table view is gray. Any clue? What's wrong with this approach? Thank you in advance.
Grouped table views have a custom view in the backgroundView
property. This custom view is what displays the background. If you want to change the background, you should create your own view and assign it there. In your case, you probably want something like the following:
UIView *bgView = [[[UIView alloc] init] autorelease];
bgView.backgroundColor = [UIColor blackColor];
bgView.opaque = YES;
self.myTableView.backgroundView = bgView;
精彩评论