iOS 6 AutoRotate在UiNavigationController中 [英] iOS 6 AutoRotate In UiNavigationController

查看:74
本文介绍了iOS 6 AutoRotate在UiNavigationController中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中有UiNavigationController。
我想只有一个屏幕可以旋转所以我放入这个类:

I have UiNavigationController in my app. I want that only one screen will be able to rotate so i put in this class :

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return YES;
}

-(BOOL)shouldAutorotate {
    return YES;
}

-(NSInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAll;
}

但发生的问题是ecery屏幕应用程序轮换发生。我怎么能禁用它?

but the problem that happen is in ecery screen the app the rotation happens. how i can disable it?

推荐答案

对于iOS 6,我在我的应用程序中使用以下代码,它允许您指定每个viewcontroller单独旋转:

For iOS 6, I am using the following code in my app, which allows you to specify rotation for each viewcontroller individually:

AppDelegate.m -

AppDelegate.m -

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{NSUInteger orientations =UIInterfaceOrientationMaskAllButUpsideDown;
if(self.window.rootViewController){
UIViewController *presentedViewController = [[(UINavigationController *)self.window.rootViewController viewControllers] lastObject];
orientations = [presentedViewController supportedInterfaceOrientations];
}
return orientations;
}

ViewController.m -

ViewController.m -

- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskPortrait;
}

原始代码的信用我相信去Ray WenderlichiOS 6 by教程书。 Ray Wenderlich网站

Credits for the code originially I believe go to the Ray Wenderlich "iOS 6 by Tutorials" book. Ray Wenderlich website

这篇关于iOS 6 AutoRotate在UiNavigationController中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆