iOS 6错误:当导航控制器用作窗口根时未调用supportedInterfaceOrientations [英] iOS 6 bug: supportedInterfaceOrientations not called when nav controller used as window root

查看:104
本文介绍了iOS 6错误:当导航控制器用作窗口根时未调用supportedInterfaceOrientations的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的mainwindow.xib中,我有一个navigationcontroller。在(作为子项)之上我有另一个viewcontroller(homeviewcontroller)。



在笔尖中我将窗口的rootviewcontroller设置为此导航控制器。



这部署到应用程序存储和工作完美。



由于升级到ios6 sdk我遇到了方向问题 - 基本上使用这种设计我的homeviewcontroller的supportedInterfaceOrientations方法在运行我的应用程序时不会被调用ios 6设备/模拟器。



为了解决这个问题,我需要将homeviewcontroller设置为窗口的rootviewcontroller,但这不是我想要的 - 我需要导航控制器。 / p>

如何解决ios6中这个烦人的错误?



更新:



我也尝试过以编程方式执行此操作 - 它仍然无效。

   - (BOOL)应用程序:(UIApplication *)应用程序didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{
HomeViewController * homeVC = [[HomeVi] ewController alloc] init];
UINavigationController * navController = [[UINavigationController alloc] initWithRootViewController:homeVC];
[self.window setRootViewController:navController];

[self.window makeKeyAndVisible];

返回YES;
}


解决方案

你需要继承UINavigationController和在那里覆盖supportedInterfaceOrientations。


In my mainwindow.xib I have a navigationcontroller. On top of (as a sub item) I have another viewcontroller(homeviewcontroller).

In the nib I have set the window's rootviewcontroller to be this navigationcontroller.

This is deployed to the app store and works perfectly.

Since upgrading to ios6 sdk I am getting orientation issues - basically with this design the supportedInterfaceOrientations method of my homeviewcontroller does not get called when running my app in ios 6 device/simulator.

In order to fix this issue I need to set homeviewcontroller as the window's rootviewcontroller however this is not what I want - I need the navigationcontroller.

How do I get around this annoying bug in ios6?

Update:

I have also tried doing this programmatically - it still doesn't work.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{        
    HomeViewController *homeVC = [[HomeViewController alloc]init];
    UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:homeVC];
    [self.window setRootViewController:navController];

    [self.window makeKeyAndVisible];

    return YES; 
}

解决方案

You need to subclass UINavigationController and override supportedInterfaceOrientations there.

这篇关于iOS 6错误:当导航控制器用作窗口根时未调用supportedInterfaceOrientations的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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