原因:出现的原因一般是运行时未给 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]];