ios 6.0应该引发问题

时间:2012-10-12 14:07:31

标签: iphone objective-c

我的应用程序商店支持ios5 +版本。当我将此应用程序部署到商店时,基本sdk设置为5.0,部署目标是ios 5.0。它目前在ios 5和6设备上正常运行。

我已将IDE升级到ios 6.0 - 基本SDK为6.0,部署目标为5.0。然而,当我在6.0模拟器或设备中运行此应用程序时,由于该消息被折旧,我得到了应该引发的问题。

  1. 为什么我的部署目标是5.0给我这些问题 - 我不想使用ios 6.
  2. 为什么我不能将我的基本sdk设置为5.0?
  3. 更新 这就是我的控制器当前的样子。不幸的是,preferredInterfaceOrientation只在每次方向改变时被调用一次 - 这对我来说没有用,因为我在这个方法中操作视图:

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
    {
        [self layoutHomeViewButtons:toInterfaceOrientation];
    
        return YES;
    }
    
    - (BOOL)shouldAutorotate
    {
        return YES;
    }
    
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
    {
        return UIInterfaceOrientationLandscapeRight;
    }
    
    - (NSUInteger)supportedInterfaceOrientations
    {
    
        [self layoutHomeViewButtons:[self getInterfaceOrientation]];
    
        return UIInterfaceOrientationMaskAll;
    }
    

    更新2: 我已经弄清楚如何获得supportInterfaceOrientations方法来调用。在我的MainWindow.xib中,我将一个navigationcontroller设置为窗口的根视图控制器。作为这个导航控制器的子项,我有我的homeviewcontroller,其中包含上面的代码。

    如果我更改此链接以使窗口的rootviewcontroller是homeviewcontroller,则调用该方法。但是我需要这个导航控制器用于我的ui!

4 个答案:

答案 0 :(得分:4)

您所描述的内容与我在切换到iOS 6时遇到的情况非常相似。它归结为在您的应用委托中处理self.window的方式。如果它适用于您的情况,基本上,您想要从

更改您的代码
[self.window addSubview:navigationController.view];

[self.window setRootViewController:navigationController];

一旦我这样做,我的旋转消息突然开始按预期发射。这是我关于这个主题的博客文章:

http://www.dosomethinghere.com/2012/09/24/the-app-delegates-uiwindow-is-finicky/

答案 1 :(得分:0)

要支持新的旋转,请执行以下方法:

// Tell the system which orientations are supporter
- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}

- (BOOL) shouldAutorotate {
    return NO;
} 

// tell the system which rotation should be used when the viewcontroller is presented.
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationLandscapeRight;
}

答案 2 :(得分:0)

没有调用这些ios6方法的原因是因为我将窗口的rootviewcontroller设置为导航控制器而不是我的homeviewcontroller,这就是为什么没有调用这些方法的原因。

这对我的解决方案没用,所以我正在寻找答案,但这确实解决了这个问题。

请参阅我的后续问题,我想弄清楚如何将我的navigationcontroller作为rootviewcontroller:iOS 6 bug: supportedInterfaceOrientations not called when nav controller used as window root

答案 3 :(得分:0)

我可以看到这个问题已经回答了。无论如何,使用Xcode 4.5时我们遇到了同样的问题。但是,如果我们使用Xcode 4.4.x构建代码,即使没有shouldAutorotate方法,自动旋转也能正常工作。因此,尝试使用Xcode 4.4.x进行构建。