您的位置:首页 > 移动开发

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

2013-08-21 14:33 471 查看


原因:出现的原因一般是运行时未给 self.window的 rootViewController的对象分配内存造成的,如下面类似例子



NSArray *item = [NSArray arrayWithObjects:nc1, nil];
        _tabBar.tabBar.backgroundImage = [UIImage imageNamed:@"tabbarbg_app.png"];
        [_tabBar setDelegate:self];
        [_tabBar setViewControllers:item];
        _tabBar.selectedIndex = 0;
        [self.window setRootViewController:_tabBar];
        [self.window setBackgroundColor:[UIColor whiteColor]];


解决方法: 为_tabBar添加内存分配即可

NSArray *item = [NSArray arrayWithObjects:nc1, nil];
_tabBar = [[UITabBarController alloc] init];
        _tabBar.tabBar.backgroundImage = [UIImage imageNamed:@"tabbarbg_app.png"];
        [_tabBar setDelegate:self];
        [_tabBar setViewControllers:item];
        _tabBar.selectedIndex = 0;
        [self.window setRootViewController:_tabBar];
        [self.window setBackgroundColor:[UIColor whiteColor]];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐