【极客班】自动旋转

自动旋转:

可以在视图控制器中指定是否允许旋转用户界面。如果用户旋转设备,活动视图控制器将被问及是否可以旋转到新的方向。如果视图控制器给予肯定的响应,那么应用程序的窗口和视图就会旋转,窗口和视图的大小会重新调整以适应新的方向。

【极客班】自动旋转_第1张图片
支持设备方向.png

Device Orientation的复选框就是指定应用程序支持的方向;并非意味着应用中的每一个视图都要支持被选中的方向,但如果想让所有的应用程序都支持某个方向,就必须在这里选中该方向。Devices下拉菜单可以选择iPhone、ipad或者Universal。
用代码实现控制某个ViewController的方向,如下:

-(NSUInteger)supportedInterfaceOrientation{
return (UIInterfaceOrientationMaskPortait|UIInterfaceOrientationMaskLandscapeLeft);
}

UIKit定义了如下方向掩码:
.UIInterfaceOrientationMaskPortait
.UIInterfaceOrientationMaskLandscapeLeft
.UIInterfaceOrientationMaskLandscapeRight
.UIInterfaceOrientationMaskPortaitUpsideDown

你可能感兴趣的:(【极客班】自动旋转)