audiophilic和Flaviu的方法都可以。但是你們都錯過了一行額外的代碼。
我發現你必須先分配和初始化UIWindow對象。我不知道爲什麼,但初始化對象解決了問題。
self.window=[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
audiophilic的做法:
self.window=[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle: nil];
ResultsInListViewController *resultsInListViewController = (ResultsInListViewController *)[mainStoryboard instantiateViewControllerWithIdentifier:@"ResultsInListViewController"];
[self.window addSubview:resultsInListViewController.view];
[self.window makeKeyAndVisible];
Flaviu的做法:
self.window=[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle: nil];
ResultsInListViewController *resultsInListViewController = (ResultsInListViewController *)[mainStoryboard instantiateViewControllerWithIdentifier:@"ResultsInListViewController"];
[self.window setRootViewController:resultsInListViewController];
[self.window makeKeyAndVisible];
如果您發現了這些問題的答案之一是正確的,你會介意將其標記爲正確 – 2013-01-01 21:44:00