Xcode IOS6:景观中的视图大小

Xcode IOS6:景观中的视图大小,xcode,ipad,uiview,uiviewcontroller,ios6,Xcode,Ipad,Uiview,Uiviewcontroller,Ios6,刚刚更新到iOSSDK6,现在我很困惑。我试图找到解决办法,但失败了 创建了一个新的单视图iPad应用程序我在xcode中有一个iPad3 在目标->摘要中禁用纵向和倒置界面方向 将模拟度量方向设置为横向 在视图控制器文件中添加了以下代码行: - (BOOL)shouldAutorotate { return YES; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { retu

刚刚更新到iOSSDK6,现在我很困惑。我试图找到解决办法,但失败了

创建了一个新的单视图iPad应用程序我在xcode中有一个iPad3 在目标->摘要中禁用纵向和倒置界面方向 将模拟度量方向设置为横向 在视图控制器文件中添加了以下代码行:

- (BOOL)shouldAutorotate {
     return YES;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    NSLog(@"%@", NSStringFromCGRect(self.view.frame));
}
运行应用程序

我的输出是:2012-10-09 18:18:40.149TestApp[6165:907]{{20,0},{7481024} 有人知道为什么框架不是。。。{{0,20},{1024,748}正如我所预料的那样?也许我错过了什么


谢谢大家!

我不认为您遗漏了什么,但是如果您使用UINavigationController包装视图控制器,帧将按预期设置

注意:在iOS 6 SDK中,您不能再将任何UIInterfaceOrientation常量组合为掩码。因此,您需要:

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationLandscapeLeft;
}
但这并不能解释问题,因为当视图控制器是UIWindow的根控制器时,不会调用preferredInterfaceOrientationForPresentation