ios在视图执行期间禁用/启用旋转

时间:2015-09-15 13:18:38

标签: ios swift rotation

我想知道在视图生命期间如何禁用/启用旋转。 有没有办法在视图生命中更新shouldAutorotate(无需重新加载视图)

感谢。

1 个答案:

答案 0 :(得分:1)

来自Apple Docs:

  • shouldAutorotate 返回一个布尔值,指示视图控制器的内容是否应自动旋转。

宣言 迅速 func shouldAutorotate() - >布尔

目标-C - (BOOL)shouldAutorotate

更多相关信息:https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/index.html#//apple_ref/occ/instm/UIViewController/shouldAutorotate

您应该将此添加到您决定用户是否可以旋转ViewController的方法中:

override func shouldAutorotate() -> Bool {
    return false
}

另请参阅:Setting device orientation in Swift iOS

相关问题