uiscreen的旋转SWIFT
Rotation of uiscreen SWIFT
我在 info.plist 文件中禁用了除纵向模式之外的所有方向模式,因为我不希望应用程序旋转。但是我希望一个视图控制器仅处于横向模式。我可以在视图控制器的 class 中以编程方式更改方向吗?或者我可以在 info.plist 中禁用自动旋转但启用纵向和横向模式吗?
我也知道我可以检查 phone 被 UIDevice.currentDevice().orientation.isLandscape
保持的方向
但是,当您以不同方式握住 phone 时,是否有一种方法可以执行?
参见 UIViewController.h shouldAutorotate 和 supportedInterfaceOrientations 方法。
如果您只想以不同于 info.plist 中大多数其他方向的方向展示一个 VC,您必须设置一组包含所有支持方向的值。
为避免 VC 以特定方向旋转的可能性,您应该覆盖
- shouldAutorotate
- supportedInterfaceOrintation
- preferredInterfaceOrientationForPresentation
你会发现这个答案和一个实际的例子也很有用How to force view controller orientation in iOS 8?
我在 info.plist 文件中禁用了除纵向模式之外的所有方向模式,因为我不希望应用程序旋转。但是我希望一个视图控制器仅处于横向模式。我可以在视图控制器的 class 中以编程方式更改方向吗?或者我可以在 info.plist 中禁用自动旋转但启用纵向和横向模式吗?
我也知道我可以检查 phone 被 UIDevice.currentDevice().orientation.isLandscape
但是,当您以不同方式握住 phone 时,是否有一种方法可以执行?
参见 UIViewController.h shouldAutorotate 和 supportedInterfaceOrientations 方法。
如果您只想以不同于 info.plist 中大多数其他方向的方向展示一个 VC,您必须设置一组包含所有支持方向的值。
为避免 VC 以特定方向旋转的可能性,您应该覆盖
- shouldAutorotate
- supportedInterfaceOrintation
- preferredInterfaceOrientationForPresentation
你会发现这个答案和一个实际的例子也很有用How to force view controller orientation in iOS 8?