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

ios6以上版本的旋转控制

2014-06-19 16:43 260 查看
1.若整个程序没有NavigationController可以直接使用以下这两方法来控制
-(BOOL)shouldAutorotate;

-(NSUInteger)supportedInterfaceOrientations;
2.若整个程序有NavigationController,则应对Nav写个类别,然后再在单个Controller里控制
Nav类别的写法:

@implementation UINavigationController (Rotation_IOS6)

-(BOOL)shouldAutorotate
{
    return [self.topViewController shouldAutorotate];
}

-(NSUInteger)supportedInterfaceOrientations
{
    return [self.topViewController supportedInterfaceOrientations];
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return [self.topViewController preferredInterfaceOrientationForPresentation];
}

@end


方法源参考:http://stackoverflow.com/questions/12803762/ios6-interface-orientation-broken
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: