[英]iOS 6 autorotation in simulator varies from actual iOS 6 device
我的应用程序不会在iOS 6 GM模拟器中自动旋转,但它在设备上使用相同版本的iOS。 这可能是一个模拟器错误吗? 该应用程序正在使用已弃用的自动旋转方法,但它们在设备本身上工作正常,这让我想知道模拟器API是否不同?
它应该仍然适用于已弃用的旋转方法,但您需要将以下内容添加到didFinishLaunchingWithOptions:
方法:
self.window.rootViewController = yourRootViewController;
这告诉主window
将旋转通知发送到哪个视图控制器。 这是iOS 6.0 SDK的新功能。
这是我为了让我的应用再次运行而添加的内容:
// 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;
}
添加以下内容还不足以使其在模拟器上运行:
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAllButUpsideDown;
}
- (BOOL) shouldAutorotate {
return YES;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationPortrait;
}
为了使它工作,我还在appDelegate类的didFinishLaunchingWithOptions函数中添加了以下内容:
self.window.rootViewController = viewController;
这次添加后我停止了以下错误: 应用程序窗口应该在应用程序启动结束时有一个根视图控制器
- (BOOL)shouldAutorotate {
return NO;
}
并将app plist文件中根视图控制器支持的旋转设置为仅纵向。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.