想必控制屏幕旋转是不少人比较关系的吧!有的人应该知道ios6并不支持 shouldAutorotateToInterfaceOrientation 而强制打开xocde的屏幕旋转方向控制,会使得有一些控件在横向的时候有错位!(简单说只有一些控制器默认支持全方位) ios
如今给出一个让APP支持横屏的例子!check it: app
1. code
2. it
在项目的AppDelegate文件加入 io
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{ return UIInterfaceOrientationMaskAll; }3
在只须要横屏的控制器内添加 class
// ios5下的旋转 im
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationIsLandscape(interfaceOrientation); }//ios6下的旋转
-(BOOL)shouldAutorotate { return YES; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; }
//若是想要全方位旋转的话那就在控制器内添加 项目
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { return YES; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskAll; } -(BOOL)shouldAutorotate { return YES; }OK搞定!至于详细我再补上 上班鸟!