【问题标题】:IOS6: Size of View in LandscapeIOS6:横向视图的大小
【发布时间】:2012-09-30 01:07:00
【问题描述】:

刚刚更新到 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. 运行应用程序

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

谢谢!

【问题讨论】:

    标签: xcode ipad uiview uiviewcontroller ios6


    【解决方案1】:

    我认为您没有遗漏任何内容,但是如果您使用 UINavigationController 包装您的视图控制器,框架将按预期设置。

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

    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
        return UIInterfaceOrientationLandscapeLeft;
    }
    

    但这并不能解释问题,因为当视图控制器是 UIWindow 的根控制器时,不会调用 preferredInterfaceOrientationForPresentation。

    【讨论】:

      猜你喜欢
      • 2013-01-05
      • 1970-01-01
      • 1970-01-01
      • 2013-03-23
      • 2012-10-23
      • 2012-12-31
      • 1970-01-01
      • 2012-09-12
      • 2016-06-28
      相关资源
      最近更新 更多