iOS 视图控制器:界面方向、手动布局与视图呈现全解析
1. 界面方向支持
在 iOS 开发中,应用支持的界面方向通过 application(_:supportedInterfaceOrientationsFor:)
或 supportedInterfaceOrientations
返回的 UIInterfaceOrientationMask
位掩码来指定。它可以是以下值之一,也可以是多个值的组合:
- .portrait
- .landscapeLeft
- .landscapeRight
- .portraitUpsideDown
- .landscape
( .left
和 .right
的组合)
- .all
( .portrait
、 .upsideDown
、 .left
和 .right
的组合)
- .allButUpsideDown
( .portrait
、 .left
和 .right
的组合)
示例代码如下: