2016-12-21 218 views
0

我正在开发一个在2011年首次创建的objective-c iOS应用程序,在2013年完成了一些更新和更改。现在,我应该让它工作,因为它正在崩溃错误:旧的iOS应用程序在启动屏幕后崩溃

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Application windows are expected to have a root view controller at the end of application launch'

中的AppDelegate

我检查:

[self.window setRootViewController:viewAfterLaunchScreen]; 

根据这个答案"Application windows are expected to have a root view controller at the end of application launch" error when running a project with Xcode 7, iOS 9

调试后,我已经注意到了,APPLI在viewWillAppear上运行rootViewController后崩溃。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; 
if ([[DAL GetPreferences:@"FIRST"] isEqualToString:@"1"]) 
{ 
    LoginViewController *lvc3 = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil]; 
    [self.window setRootViewController:lvc3]; 
    [lvc3 release]; 
} 
else if(_window.rootViewController == nil){ 

    PagingViewController *lvc2 = [[PagingViewController alloc] initWithNibName:@"PagingViewController" bundle:nil]; 
    [self.window setRootViewController:lvc2]; 
    [lvc2 release]; 
} 
[DAL SavePreference:@"FIRST" :@"1"]; 
[self.window makeKeyAndVisible]; 
return YES; } 
+1

[“应用程序窗口的可能的复制预计将有在根视图控制器结束应用程序启动“错误时运行与Xcode 7,iOS 9项目](http://stackoverflow.com/questions/30884896/application-windows-are-expected-to-have-a-root-view-controller-在末尾) – Mahesh

+0

@Mahesh我已经检查了这个答案之前发布我的问题,我已经提到,我已经检查了setRootViewController。 –

+0

显示你的'didFinishLaunchingWithOptions'方法。 – Mahesh

回答

0

这个“老”项目的年龄?如果它是比几年多,你还有:

[window addSubview:viewController.view]; 

而是应该将其替换为:

[window setRootViewController:viewController];