8

我的应用程序不会在 iOS 6 GM 模拟器中自动旋转,但它会在设备上使用相同版本的 iOS。这可能是模拟器错误吗?该应用程序正在使用已弃用的自动旋转方法,但它们在设备本身上运行良好,这让我想知道模拟器 API 是否不同?

4

4 回答 4

15

它仍应与已弃用的旋转方法一起使用,但您需要将以下内容添加到您的didFinishLaunchingWithOptions:方法中:

self.window.rootViewController = yourRootViewController;

这告诉主window视图控制器将旋转通知发送到哪个视图控制器。这是 iOS 6.0 SDK 的新功能。

于 2012-09-27T13:34:27.777 回答
11

这是我添加的让我的应用程序再次运行的内容:

// Tell the system what we support
- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAllButUpsideDown;
}

// Tell the system It should autorotate
- (BOOL) shouldAutorotate {
    return YES;
}

// Tell the system which initial orientation we want to have
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationPortrait;
}
于 2012-09-13T14:04:00.877 回答
0

添加以下内容不足以使其在模拟器上运行:

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAllButUpsideDown;
}
- (BOOL) shouldAutorotate {
    return YES;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationPortrait;
}

为了使它工作,我还在 appDelegate 类的 didFinishLaunchingWithOptions 函数中添加了以下内容:

self.window.rootViewController = viewController;

添加后我不再收到以下错误: 应用程序窗口应该在应用程序启动结束时有一个根视图控制器

于 2012-09-26T18:06:02.747 回答
0
- (BOOL)shouldAutorotate {
    return NO;
}

并将 app plist 文件中根视图控制器的支持旋转设置为仅纵向。

于 2013-01-25T06:23:53.280 回答