我在控制台中收到以下错误:
应用程序在应用程序启动结束时应具有根视图控制器
以下是我的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;
}
Run Code Online (Sandbox Code Playgroud)
在Interface Builder中,UITabBarController代理连接到App Delegate.
有谁知道如何解决这个问题?
我正在尝试将我的iPhone应用程序转换为通用应用程序.我将设备切换到Universal并让Xcode为我做了一个MainWindow-iPad.xib的事情,现在当我在iPhone模拟器中运行应用程序时,它工作正常,但是当我在iPad模拟器中运行它时,我得到一个白色屏幕和Application windows are expected to have a root view controller at the end of application launch错误.我已经阅读了一些关于同样问题的其他帖子,但没有一个仅限于一个设备.
这是我的application:didFinishLaunchWithOptions:方法:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
/* some dropbox setup stuff */
// INIT VIEW AND CORE DATA
RootViewController *rootViewController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
NSManagedObjectContext *context = [self managedObjectContext];
if (!context) {
// Handle the error.
}
rootViewController.managedObjectContext = context;
UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
self.navigationController = aNavigationController;
[_window addSubview:[_navigationController view]];
[_window makeKeyAndVisible];
[rootViewController release];
[aNavigationController release]; …Run Code Online (Sandbox Code Playgroud)