2014-05-08 23 views
0

Stack Overlow有關於此錯誤的一些問題,但沒有一個解決方案似乎適用於我。有人能夠看一下我的代碼,看看爲什麼我得到以下錯誤?關於在應用程序啓動結束時擁有根視圖控制器的錯誤消息

應用預計將有在應用程序啓動的最後一個根視圖控制器

AppDelegate.m:

#import "AppDelegate.h" 
#import "ViewController.h" //import header file 

@implementation AppDelegate 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
    // Override point for customization after application launch. 
    UIStoryboard* sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 
    UIViewController* viewController = [sb instantiateViewControllerWithIdentifier:@"viewController"]; 
    self.window.rootViewController = self.viewController; 
    [self.window makeKeyAndVisible]; 
    return YES; 
} 

@end 
+1

更新通過粘貼你的問題(和格式)的相關代碼:

試試這個。 – rmaddy

+0

做我做的事情會不會更好? – user3525783

+1

關於SO的問題需要自成一體,以便將來仍然有用。請包括重現問題所需的_minimum_代碼,而不是鏈接,而不是所有的代碼。此外,鑑於此問題已多次提出,請更詳細地解釋您嘗試過的內容以及爲什麼其他解決方案不適合您。 –

回答

1

您設置rootViewControllerself.viewController但你永遠不設置self.viewController 。在

self.viewController = [sb instantiateViewControllerWithIdentifier:@"viewController"]; 
self.window.rootViewController = self.viewController; 
+0

工作。謝謝!! – user3525783

相關問題