您的位置:首页 > 移动开发 > IOS开发

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

2014-03-12 14:46 274 查看
想必控制屏幕旋转是很多人比较关系的吧!有的人应该知道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搞定!至于详细我再补上 上班鸟!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: