“应用程序窗口期望具有根视图控制器”条件外观 [英] "Application windows are expected to have a root view controller" conditional appearance

查看:126
本文介绍了“应用程序窗口期望具有根视图控制器”条件外观的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Xcode 4.5和iOS6为iPhone撰写应用程式。我还创建了一个新的 UIWindow ,以便能够管理状态栏的区域(以显示消息等)
我使用storyboards和我的 appDelegate 方法如下所示:

   - :(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{
return YES;
}

控制台中不会出现 我把它放在 viewDidAppear 的方法中:

   - (void) viewDidAppear:(BOOL)animated {

if(!window){
window = [[SGStatusBar alloc] initWithFrame:CGRectZero];
window.frame = [[UIApplication sharedApplication] statusBarFrame];
window.alpha = 0.5f;

[self.view.window makeKeyAndVisible]; //必须是app的主窗口
window.hidden = NO;
}
}

同样的方法,放在 viewDidLoad 在控制台中发出警告:

  2012-12-27 11:34: 20.838 NewApp [433:c07]应用程序窗口应用程序启动结束时应具有根视图控制器

这是因为我创建了一个新的 UIWindow ?为什么这两种方法之间的区别如此之大?



而且,最重要的是,如何摆脱此警告,将代码放在 viewDidLoad 方法?



编辑:同样的问题这里,但它不是我想解决它的方式(它实际上是我解决它的方式

现在)



我已经尝试将当前的ViewController设置为我的窗口的根视图控制器:

  ViewController * vcB = [[UIViewController alloc] init]; 
window.rootViewController = vcB;

但我不断收到警告:

 初始化'ViewController * __ strong'与类型为'UIViewController *'的表达式不兼容的指针类型


解决方案

设置 window.rootViewController 属性。


I'm writing an app for iPhone using Xcode 4.5 and iOS6. I'm also creating a new UIWindow to be able to manage the area of the status bar (to display messages there, etc.) I'm using storyboards and my appDelegate method looks like this:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    return YES;
}

The message does not appear in the console when I put it in the method called viewDidAppear:

- (void)viewDidAppear:(BOOL)animated     {

    if (!window) {
        window = [[SGStatusBar alloc] initWithFrame:CGRectZero];
        window.frame = [[UIApplication sharedApplication] statusBarFrame];
        window.alpha = 0.5f;

        [self.view.window makeKeyAndVisible]; // has to be main window of app
        window.hidden = NO;
    }  
}

The same method, put in the viewDidLoad gives a warning in the console:

2012-12-27 11:34:20.838 NewApp[433:c07] Application windows are expected to have a root view controller at the end of application launch

Is this because I've created a new UIWindow? Why the difference between those two methods is so big?

And, most importantly, how can I get rid of this warning while putting the code in the viewDidLoad method?

EDIT:

I have encountered the same problem here, but it's not the way I'd like to solve it (it's actually the way I'm solving it right now)

I've tried setting my current ViewController as my window's root view controller by doing this:

ViewController *vcB = [[UIViewController alloc] init];
window.rootViewController = vcB;

But I keep getting a warning that says:

Incompatible pointer types initializing 'ViewController *__strong' with an expression of type 'UIViewController *'

解决方案

Set window.rootViewController property .

这篇关于“应用程序窗口期望具有根视图控制器”条件外观的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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