iPad - UISplitViewController - 背景颜色

时间:2011-01-28 04:30:10

标签: ipad uisplitviewcontroller background-color

我有一个UISplitViewController设置,但由于某种原因,在你旋转一次之后背景才会保持不变。

我使用IB设置拆分视图并将详细视图设置为IPadDetailViewController。在里面,我有以下内容:

- (void)loadView {
    [super loadView];

    self.view.backgroundColor = [UIColor greenColor];

    toolbar = [[UIToolbar alloc] initWithFrame:CGRectZero];
    toolbar.barStyle = UIBarStyleDefault;
    [toolbar sizeToFit];
    [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];

    }   
}

虽然代码运行并且我的工具栏位于顶部,但视图仍然是黑色的(它以模拟器的横向开始)。

任何想法为什么?

1 个答案:

答案 0 :(得分:0)

尝试在iPad DetailViewController中的awakeFromNib方法中设置背景颜色