ios 随手篇 关于ios5/ios6屏幕旋转问题

想必控制屏幕旋转是很多人比较关系的吧!有的人应该知道ios6并不支持 shouldAutorotateToInterfaceOrientation
而强制打开xocde的屏幕旋转方向控制,会使得有一些控件在横向的时候有错位!(简单说只有一些控制器默认支持全方位)

现在给出一个让APP支持横屏的例子!check it:

1.

2.

在项目的AppDelegate文件加入

1
2
3
4
5
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{

return UIInterfaceOrientationMaskAll;

}

3

在只需要横屏的控制器内添加

// ios5下的旋转

1
2
3
4
5
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

return UIInterfaceOrientationIsLandscape(interfaceOrientation);

}

//ios6下的旋转

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
-(BOOL)shouldAutorotate {

return YES;

}

-(NSUInteger)supportedInterfaceOrientations {

return UIInterfaceOrientationMaskLandscape;

}

//如果想要全方位旋转的话那就在控制器内添加

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {

return YES;

}



-(NSUInteger)supportedInterfaceOrientations {

return UIInterfaceOrientationMaskAll;

}



-(BOOL)shouldAutorotate {

return YES;

}

OK搞定!至于详细我再补上 上班鸟!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值