1

刚刚更新到 IOS SDK 6,现在我很困惑。试图找到解决方案,但我失败了。

  1. 在 xcode 中创建了一个新的“Single View iPad APP”(我有一个 iPad 3)
  2. 在 TARGETS->Summary 中禁用 Portrait & Upside-Down 界面方向
  3. 将模拟指标“方向”设置为“横向”
  4. 在视图控制器文件中添加了以下代码行:

    - (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));
    }
    
  5. 运行APP

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

谢谢!

4

1 回答 1

0

我不认为你错过了任何东西,但如果你用 a 包裹你的视图控制器UINavigationController,框架将按预期设置。

注意:使用 iOS 6 SDK,您不能再将任何 UIInterfaceOrientation 常量组合为掩码。所以你需要:

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationLandscapeLeft;
}

但是,这并不能解释问题,因为当视图控制器是UIWindow.

于 2012-10-22T18:48:21.867 回答