关于iOS中支持屏幕取向的讲解

可以通过设置 VC对应的 XIB 中 View 的show attrubite inspector属性,更改其 Orientation为 Landscape,即可默认为横屏布局。
我们可以通过3种方式设置 App界面的取向。

第一种:通过全局设置
// The system only calls this method if the application delegate has not
// implemented the delegate equivalent. It returns the orientations specified by
// the application's info.plist. If no supported interface orientations were
// specified it will return UIInterfaceOrientationMaskAll on an iPad and
// UIInterfaceOrientationMaskAllButUpsideDown on a phone.  The return value
// should be one of the UIInterfaceOrientationMask values which indicates the
// orientations supported by this application.
- (NSUInteger)supportedInterfaceOrientationsForWindow:(UIWindow *)window NS_AVAILABLE_IOS(6_0);

第2种,通过Deployment Info下的 Device Orientation 中选择取向,当然这里和 Plist 文件里Supported interface orientations对应的取向一致,改变一个地方另一个地方也会随之改变。

第3种,单一的设置 VC 做支持的取向。通过函数(iOS 6.0以后)
- (BOOL)shouldAutorotate{
return YES;
}

- (NSUInteger)supportedInterfaceOrientations{
   return UIInterfaceOrientationMaskLandscape;
}
可以设置当前 VC 所支持的方向。

最终视图所支持的取向由这3个的交集决定。需要注意的是Plist 文件里所支持的方向,会按照第一项来执行。(若支持)

参考资料: http://www.tuicool.com/articles/e2q6zi, 
图片:横屏布局.png 

转载于:https://www.cnblogs.com/iOS-kk/p/5207515.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值