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.plistSupported interface orientations中加入所有方向的支持
2 AppDelegate中加入方法 -(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{ return UIInterfaceOrientationMaskAll;} iOS6中为了后续支持任何方向的旋转
3 任何你想控制旋转的界面中加入方法
// iOS6.0
-(NSUInteger)supportedInterfaceOrientations{
 
    return UIInterfaceOrientationMaskPortrait// 可以修改为任何方向
}
 
-(BOOL)shouldAutorotate{
 
    return YES;
}
 
// iOS5.0
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
 
    return (toInterfaceOrientation == UIInterfaceOrientationPortrait);  // 可以修改为任何方向
}
这样你的app就可以同时支持iOS5和iOS6系统的横竖屏切换了
 
posted @ 2013-03-25 11:40  清风拂月晓  阅读(156)  评论(0编辑  收藏  举报