【发布时间】:2011-11-23 04:09:20
【问题描述】:
我在控制台中收到以下错误:
应用程序在应用程序启动结束时应该有一个根视图控制器
下面是我的application:didFinishLaunchWithOptions方法:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Set Background Color/Pattern
self.window.backgroundColor = [UIColor blackColor];
self.tabBarController.tabBar.backgroundColor = [UIColor clearColor];
//self.window.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"testbg.png"]];
// Set StatusBar Color
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
// Add the tab bar controller's current view as a subview of the window
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
在 Interface Builder 中,UITabBarController 的委托与 App Delegate 挂钩。
有人知道如何解决这个问题吗?
【问题讨论】:
-
在你做分配之前做一个 self.tabBarController 的 NSLog。仅当控制器为 nil 时才会触发该消息。如果它为 nil,并且您已确保连接正确,请尝试在代码中实例化控制器。
-
尝试评论窗口的初始化..检查这个答案stackoverflow.com/a/33958144/1293445
标签: ios objective-c