Xcode 5上没有根视图控制器错误

时间:2014-06-23 10:55:43

标签: xcode

我在Xcode 5上收到此错误:

Application windows are expected to have a root view controller at the end of application launch

我的代码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    [Flurry startSession:@"HJ4X7X6PB3942VGHQWWZ"];
    screenRect = [[UIScreen mainScreen] applicationFrame];
    if (screenRect.size.height > 500)
    {
        isFive = YES;
        NSLog(@"is iPhone 5");
    }else{
        isFive = NO;
    }
    [[SQLiteOperator sharedOperator] openDatabase];
    [self setupLang];
    [self handleTabBarLanguage];
    [self handleAppUpdatePopUpLanguage];

    _banner_view_controller = [[BannerViewController alloc] initWithNibName:@"BannerViewController" bundle:nil];
    [_banner_view_controller send_request];
    [_banner_view_controller didHidden];
    [_navigation_controller.view addSubview:_banner_view_controller.view];
    [CoreData sharedCoreData].banner_view_controller = _banner_view_controller;


    // Create content and menu controllers
    //
    DEMONavigationController *navigationController = [[DEMONavigationController alloc] initWithRootViewController:[[DEMOHomeViewController alloc] init]];
    DEMOMenuViewController *menuController = [[DEMOMenuViewController alloc] initWithStyle:UITableViewStylePlain];

    // Create frosted view controller
    //
    REFrostedViewController *frostedViewController = [[REFrostedViewController alloc] initWithContentViewController:navigationController menuViewController:menuController];
    frostedViewController.direction = REFrostedViewControllerDirectionLeft;
    frostedViewController.liveBlurBackgroundStyle = REFrostedViewControllerLiveBackgroundStyleLight;

    // Make it a root controller
    //
    self.window.rootViewController = frostedViewController;
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;

}

1 个答案:

答案 0 :(得分:1)

如果您正在使用故事板,请单击Xco​​de中项目导航器中的项目名称。然后查找部署信息。选择主界面作为故事板名称。在app delegate.m

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
//    // Override point for customization after application launch.
//    self.window.backgroundColor = [UIColor whiteColor];
//    [self.window makeKeyAndVisible];
    return YES;
}

现在尝试一下。