简单的来说用xcode4.5直接创建的项目是直接支持 ios6.0横竖屏的,但是用IOS5.0的模拟器运行发现不支持横竖屏,这时候就要把以前的 横竖屏函数搬出来了。
针对横屏示例:
// ios5下的横屏
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
// ios6下的横屏
-(BOOL)shouldAutorotate {
return YES;
}
-(NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
对于有 navigation的 IOS6的需求,A(竖屏) 推出的B B要只能横屏,这时候就需要实现一个navigation的子类的,然后在这个子类实现如下的代码
-(NSUInteger)supportedInterfaceOrientations{
if([[self topViewController] isKindOfClass:[SubSubView class]])
return UIInterfaceOrientationMaskAllButUpsideDown;
return UIInterfaceOrientationMaskPortrait;
}
-(NSUInteger)supportedInterfaceOrientations{
if([[self topViewController] isKindOfClass:[SubSubView class]])
return UIInterfaceOrientationMaskAllButUpsideDown;
else
return UIInterfaceOrientationMaskPortrait;
}
然后 再在B里面实现转屏的函数就可以了。