【问题标题】:Modal dismissals do not account for status bar (new iOS 6 issue?)模态解雇不考虑状态栏(新的 iOS 6 问题?)
【发布时间】:2012-09-16 01:01:36
【问题描述】:

在我开始为 iOS 6 调整我的应用程序之前根本没有这个问题。每当我从模态 segue(使用dismissViewControllerAnimated:completion:) 返回时,我的主视图都会向上移动大约状态栏的高度偏移量(并且随后位于状态栏的后面)。

我发现的唯一解决方法是添加:

self.navigationController.view.frame = CGRectMake(0, 20, 320, 460);
self.view.frame = CGRectMake(0, 0, 320, 416);

到我的 dismissViewControllerAnimated:completion 方法(这些值适用于 iPhone

不知道这个问题是如何产生的。我的怀疑是,在 segue 的某个地方,导航控制器之一丢失了状态栏的存在(以某种方式链接到新的状态栏?)。

编辑: 主视图的屏幕截图,模态解除后。 [注:底部20px空白]

【问题讨论】:

    标签: xcode frame ios6 offset statusbar


    【解决方案1】:

    解决了这个问题。我的自定义navigationControllersupportedInterfaceOrientations 返回UIInterfaceOrientationPortrait,而不是UIInterfaceOrientationMaskPortrait

    【讨论】:

      【解决方案2】:

      您的回答对我也不起作用,但我发现 Mike Foster 的这个解决方案确实做到了: http://fostah.com/ios/2012/09/27/ios6-orientation-handling.html

      他的步骤是:

      1. 添加应用程序 supportedInterfaceOrientation 并让它返回 UIInterfaceOrientationMaskAll(或者在我的情况下我使用 AllButUpsideDown)
      2. 在你的 rootViewController 中实现 shouldAutorotate 并让它返回 NO
      3. 不要在你的 rootViewController 中实现supportedInterfaceOrientations(这似乎是导致我的状态栏出现问题的步骤)
      4. 在应为横向的 viewController 中实现 shouldAutorotate 以返回 NO 和 supportedInterfaceOrientations 以返回 UIInterfaceOrientationMaskLandscape

      希望这对其他人有所帮助。

      【讨论】:

        【解决方案3】:

        这个答案对我不起作用,即使我具有与 rootViewController 相同的自定义 navigationController 结构。在我的应用中,除了我的模态框(UIInterfaceOrientationMaskAll)之外,我希望所有 VC 都使用它。

        起作用的是您的解决方法有所不同,除了它将考虑 iPhone 4 和 iPhone 5 的屏幕尺寸和导航栏的高度:

        [yourParentVC dismissViewControllerAnimated:NO completion:^{
        
            [yourParentVC.view setFrame:CGRectMake(0, 0, [UIScreen mainScreen].applicationFrame.size.width, [UIScreen mainScreen].applicationFrame.size.height-44)];
            //your other completion code
        }];
        

        +1 提出这个问题...不高兴它为 iOS 6 中的所有弃用做了多少工作,所以每一点都有帮助。

        【讨论】:

          猜你喜欢
          • 2011-11-24
          • 1970-01-01
          • 1970-01-01
          • 2017-08-16
          • 1970-01-01
          • 2012-09-12
          • 2015-12-05
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多