iPad - UISplitViewController - Background color
I have a UISplitViewController setup, but for some reason the background isn't taking hold until you've rotated it once.
I use IB to setup the split view and set the detail view to be IPadDetailViewController
. Inside that I have the following:
- (void)loadView {
[super loadView];
self.view.backgroundColor = [UIColor greenColor];
toolbar = [[UIToolbar alloc] initWithFrame:CGRectZero];
toolbar.barStyle = UIBarStyleDefault;
[toolbar siz开发者_如何学GoeToFit];
[self.view addSubview:toolbar];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
self.view.backgroundColor = [UIColor orangeColor];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
self.interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
NSLog(@"it is in landscape!");
self.view.backgroundColor = [UIColor grayColor]];
}
else {
NSLog(@"it is in portrait!");
self.view.backgroundColor = [UIColor blueColor];
}
}
Though the code gets run and my toolbar gets place at the top, the view remains black (it starts in landscape for the Simulator).
Any ideas why?
try setting the background color in awakeFromNib method in your iPadDetailViewController
精彩评论