我的第一个 View Controller 是 LoginViewController。我正在尝试支持 iOS 6 上的自动旋转管理。
我已经实现了 shouldAutorotate 而不是 shouldAutorotateToInterfaceOrientation,如下所示:
-(BOOL)shouldAutorotate {
UIInterfaceOrientation toInterfaceOrientation = [[UIDevice currentDevice] orientation];
return [DeviceSupport isOrientationSupported:toInterfaceOrientation];
}
shouldAutorotate
在应用程序启动时被调用五次。 toInterfaceOrientation 值按顺序排列且不改变 ipad 方向:0、0、0、4 和 4。首先,为什么应用需要这么长时间才能将正确的方向放入 currentDevice?为什么 shouldAutorotate 被调用了五次?
当方向为 4 时,[DeviceSupport isOrientationSupported:toInterfaceOrientation]
返回 true。但是我的应用程序不旋转。
在我的 info.plist 中:
Supported interface orientations
=> Item 0: Portrait (bottom home button)
=> Item 1: Portrait (top home button)
Supported interface orientations (iPad)
=> Item 0: Landscape (left home button)
=> Item 1: Landscape (right home button)
有什么想法吗?谢谢。
最佳答案
更改您的代码:
[self.window addSubview:aController.view];
此代码:
self.window.rootViewController = aController;
同时添加以下方向支持方法
shouldAutorotate -return YES
supportedInterfaceOrientations- 返回 UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft;
关于objective-c - shouldAutorotate 返回 true 但不旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13290572/