2013-01-18 16 views
0

可能重複:
Applications are expected to have a root view controller at the end of application launch怪異控制檯消息 - 應用窗口被預期在應用程序啓動的端部有一個根視圖控制器

我的應用程序使用的UITabBarController和幾個導航控制器。它可以在模擬器和真實設備上運行。然而,什麼讓我感到不安,是我在控制檯上啓動應用程序的消息。 Application windows are expected to have a root view controller at the end of application launch

我已經使用了它,但我無法找到我的問題的答案。 強制性的appDelegate didFinishLaunchingWithOptions

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    // Override point for customization after application launch. 
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 
    [defaults setBool:FALSE forKey:@"loggedIn"]; 
    [defaults setInteger:0 forKey:@"token"]; 
    [defaults synchronize]; 

    _window.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"app_bg.png"]]; 

return YES; 
} 

我的main.m代碼

int main(int argc, char *argv[]) 
{ 
    @autoreleasepool { 
     return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 
    } 
} 

我會很高興,如果有人可以幫助我:)謝謝您!

+0

您的UI設置如何?你在使用故事板嗎?如果沒有,MainWindow.XIB中發生了什麼? – Stavash

+0

另外,您的應用程序委託類實際上是否名爲「AppDelegate」? – Stavash

回答

0

嘗試在didFinishLaunchingWithOptions中設置窗口的根視圖控制器。如果是導航控制器,請輸入:

UINavigationController *nav = (UINavigationController *)self.window.rootViewController; 
相關問題