App Opening to Blank Black Screen

大兔子大兔子 提交于 2020-01-16 18:55:48

问题


I am making an app that embeds a navigationcontroller into a tabbarcontroller. Now when I open the app I am getting just a blank black screen.

Here is my code

PDCFirstViewController *viewController1 = [[PDCFirstViewController alloc] 
initWithNibName:@"PDCFirstViewController" bundle:nil];

PDCSecondViewController *viewController2 = [[PDCSecondViewController alloc] 
initWithNibName:@"PDCSecondViewController" bundle:nil];

ViewController *viewController3 = [[ViewController alloc] 
initWithNibName:@"ViewController" bundle:nil];
UINavigationController *navigationcontroller = [[UINavigationController alloc] 
initWithRootViewController:viewController3];

self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray  
arrayWithObjects:viewController1,viewController2,navigationcontroller, nil];

[self.window makeKeyAndVisible];

Do I need to add something or do something different to make the app display? Any assistance would be great! Thank you!


回答1:


You are missing rootviewcontroller

Add this

self.window.rootViewController = self.tabBarController;

Hope it helps you..




回答2:


self.window.rootViewController = self.tabBarController;



回答3:


self.window.rootViewController = self.tabBarController;

That should do it



来源:https://stackoverflow.com/questions/13836189/app-opening-to-blank-black-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!