iOS5和iOS6横竖屏同时支持

iOS5和iOS6横竖屏同时支持

iOS6中抛弃了- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation方法,为了同时支持iOS5和iOS6系统的横竖屏切换,可用如上代码
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
1 info .plist Supported interface orientations中加入所有方向的支持
2 AppDelegate中加入方法 -(NSUInteger)application:( UIApplication *)application supportedInterfaceOrientationsForWindow :( UIWindow *)window{ return UIInterfaceOrientationMaskAll ;} iOS 6 中为了后续支持任何方向的旋转
3 任何你想控制旋转的界面中加入方法
// iOS6.0
-(NSUInteger)supportedInterfaceOrientations{
 
    return UIInterfaceOrientationMaskPortrait // 可以修改为任何方向
}
 
-( BOOL )shouldAutorotate{
 
    return YES ;
}
 
// iOS5.0
-( BOOL )shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
 
    return (toInterfaceOrientation == UIInterfaceOrientationPortrait);  // 可以修改为任何方向
}
这样你的app就可以同时支持iOS 5 和iOS 6 系统的横竖屏切换了
 

转载于:https://www.cnblogs.com/ls159789/archive/2013/03/25/2980445.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值