ios sdk6 中强制横屏显示界面的方法

本文介绍了如何在iOS 6.0中处理屏幕旋转的问题,特别是针对shouldAutorotateToInterfaceOrientation方法被废弃的情况。通过实现supportedInterfaceOrientations方法可以正确设置应用的界面方向。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ios 6.0中shouldAutorotateToInterfaceOrientation被设为deprecated ,需追加supportedInterfaceOrientations方法来响应屏幕响应

有一点要说明,在ios 6.0中supportedInterfaceOrientations设定的旋转的方向在plist的Supported interface orientations中必须存在,必须一一对应,否则会报错,在 ios 6.0之前无论plist中是否存在,强制指定就可以,所以要先判断设备版本号,并读取plist中Supported interface orientations中支持的方向来设定旋转方向. 

追加这2个方法处理。就可以在竖向设备的时候,横屏显示 view

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscapeRight;
}



评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值