游戏不会在iOS 8 / iPhone上自动旋转

时间:2015-01-13 20:19:47

标签: ios iphone

我有一个仅限风景的游戏,可自动旋转以下内容:

  • iOS 6 +上的任何iPad
  • iOS 7上的iPhone 4S

但不是:

  • iOS 8上的iPod 5
  • iOS 8上的iPhone 5S
  • iOS 8上的iPhone 6/6 +

这些是我可以访问的配置。我使用的故事板只有一个UIView填充屏幕,没有自动布局或任何东西。以下代码位于我的视图控制器中:

-(BOOL)shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}

旋转时,所有设备都会按预期调用此方法。在iPad上,我可以看到willRotateToInterfaceOrientation:duration:然后是didRotateFromInterfaceOrientation:被调用。这些方法永远不会触发我的iOS 8手机。我的plist包括以下内容:

<key>UISupportedInterfaceOrientations</key>
<array>
    <string>UIInterfaceOrientationLandscapeLeft</string>
    <string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
    <string>UIInterfaceOrientationLandscapeLeft</string>
    <string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~iphone</key>
<array>
    <string>UIInterfaceOrientationLandscapeLeft</string>
    <string>UIInterfaceOrientationLandscapeRight</string>
</array>

我在这里没有想法 - 为什么我的应用会在iOS 8手机上旋转?

[更新]我已将其缩小为其他内容:我用来根据设备选择故事板的代码,在我的应用代表中:

if (width == 480)
{
    // Instantiate a new storyboard object using the storyboard file named Storyboard_iPhone

    UIStoryboard *iPhone35Storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];

    // Instantiate the initial view controller object from the storyboard
    UIViewController *initialViewController = [iPhone35Storyboard instantiateInitialViewController];

    // Instantiate a UIWindow object and initialize it with the screen size of the iOS device
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    // Set the initial view controller to be the root view controller of the window object
    self.window.rootViewController  = initialViewController;

    // Set the window object to be the key window and show it
    [self.window makeKeyAndVisible];
}

if (width == 568)
{   // iPhone 5 and iPod Touch 5th generation: 4 inch screen
    // Instantiate a new storyboard object using the storyboard file named Storyboard_iPhone4
    UIStoryboard *iPhone4Storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone_4in" bundle:nil];

    UIViewController *initialViewController = [iPhone4Storyboard instantiateInitialViewController];
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.rootViewController  = initialViewController;
    [self.window makeKeyAndVisible];
}

0 个答案:

没有答案