想必控制屏幕旋转是很多人比较关系的吧!有的人应该知道ios6并不支持 shouldAutorotateToInterfaceOrientation
而强制打开xocde的屏幕旋转方向控制,会使得有一些控件在横向的时候有错位!(简单说只有一些控制器默认支持全方位)
现在给出一个让APP支持横屏的例子!check it:
1.
2.
在项目的AppDelegate文件加入
|
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
return UIInterfaceOrientationMaskAll;
}
|
3
在只需要横屏的控制器内添加
// ios5下的旋转
|
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
|
//ios6下的旋转
|
-(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搞定!至于详细我再补上 上班鸟!