iphone - View Controller 不会自动旋转到纵向倒置

标签 iphone ios objective-c autorotate

我已经实现了一个仅用于自动旋转的 View Controller 。所以这个 View Controller ,我称之为 RotatableViewController , 实现这些方法:

- (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationPortrait;
}

- (NSUInteger) supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}

- (BOOL) shouldAutorotate {
    return YES;
}

它应该自动旋转到所有方向,我还检查了目标中支持的界面方向:

enter image description here

但令人难以置信的是,它不会在纵向倒置方向上自动旋转:

enter image description here

可能是什么问题呢?

PS 在 iOS 6.1 中, View Controller 通过 Storyboard 进行实例化。

最佳答案

问题是您使用的是 UINavigationController ,在 iPhone 上默认不支持倒置。作为一般设计原则,iPhone 应用程序不应支持倒置(据称是因为 iPhone 上的“锁定”开关确实锁定了横向模式,这与 iPad 不同)。倒置方向仅适用于 iPad 设备。

你可以通过继承 UINavigationController 来解决你的问题并使用 supportedInterfaceOrientations返回 UIInterfaceOrientationMaskAll并将其指定为 Storyboard 中导航 Controller 的基类。但我不认为你应该这样做,因为 iPhone 上的应用程序通常不支持倒置纵向。

关于iphone - View Controller 不会自动旋转到纵向倒置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18562892/

相关文章:

iphone - 离线时特定时区的iOS“实时”

iphone - 服务器无法识别 iPhone 中 HTTP header SOAPAction 的值?

iphone - 在 objective-c(iphone 版本)中做观察者/可观察者的最好方法是什么

iphone - 如何禁用UIWebview中的放大镜?

ios - 在 IOS 应用程序中实现我的想法的合理方法是什么?

iphone - 选择多张图片

ios - 用于视网膜显示屏的所有 iDevices 的图像后缀

ios - 恢复应用程序时,ios 上的密码保护屏幕出现延迟

ios - 在通知服务扩展和主应用程序之间共享数据

objective-c - ASIHTTPRequest 下载大型 PDF 导致 iPad 崩溃