[英]Lock Portrait Orientation in IOS on Application Boot from Landscape
So i've run into a fun little bug. 因此,我遇到了一个有趣的小错误。 I have a UINavigationController with several subviews that it will display that we only want to be viewable in Portrait View.
我有一个带有几个子视图的UINavigationController,它将显示我们只希望在人像视图中可见。 To achieve this we subclassed the UINavigationController and added the following:
为此,我们将UINavigationController子类化,并添加了以下内容:
override func shouldAutorotate() -> Bool {
return false
}
override func supportedInterfaceOrientations() -> Int {
return Int(UIInterfaceOrientationMask.Portrait.rawValue)
}
This works great, and the app is locked into Portrait and cannot rotate EXCEPT if the user turns the device sideways and then loads the app from landscape. 这样效果很好,并且如果用户侧向旋转设备,然后从横向加载应用程序,则该应用程序将锁定为“纵向”,并且无法旋转。 The expected outcome was for the device to load in portrait, however it loads in landscape, and won't let the user rotate back to portrait ever.
预期的结果是设备以纵向加载,但是以横向加载,并且永远不会让用户旋转回纵向。
The only way I've been able to replicate this is by loading the app from a device already in landscape mode. 我能够复制此内容的唯一方法是从已经处于横向模式的设备加载应用程序。 Any ideas?
有任何想法吗? There are lots of posts about device orientation, but none I could find talking about on app boot.
关于设备定位的文章很多,但是在应用程序启动时我找不到任何讨论。
删除自动旋转,它应该可以正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.