iOS 9.0 Tabbar 自动隐藏,viewcontroller 推送消失

iOS 9.0 Tabbar hide automatically and viewcontroller disappear in push

我有一个带有 4 个选项卡的 TabBarController。当我从选项卡中推送 ViewController 时,该选项卡会自动隐藏,并且在视图中不显示任何内容。但是 ViewController 包含一个带有数据的表视图。我已经实现了 tableview delegate also.I 我没有得到 tableview delegate 日志。

在 appdelegate didFinishLaunchingWithOptions() 中

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

self.homeScreen = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
self.rootNav = [[UINavigationController alloc]initWithRootViewController:self.homeScreen];

self.window.rootViewController = self.rootNav;

[self.window makeKeyAndVisible];

在此处加载 TabBar:

 myAppDelegate.myTabBarController.selectedIndex = 0;
myAppDelegate.myTabBarController.tabBar.translucent = NO;
myAppDelegate.myTabBarController.tabBar.opaque = YES;


location_select *tab1 = [[location_select alloc] initWithNibName:@"location_select" bundle:nil];
tab1.tabBarItem.image = [UIImage imageNamed:@"Restaurants.png"];
location_select *tab2 = [[location_select alloc] initWithNibName:@"location_select" bundle:nil];
tab2.title = @"Cart";
tab2.tabBarItem.image = [UIImage imageNamed:@"Cart.png"];
Deal_ViewController *tab3 = [[Deal_ViewController alloc] initWithNibName:@"Deal_ViewController" bundle:nil];
tab3.title = @"Deals";
tab3.tabBarItem.image = [UIImage imageNamed:@"Deals.png"];

MoreViewController *tab4 = [[MoreViewController alloc] initWithNibName:@"MoreViewController" bundle:nil];
tab4.title = @"More";
tab4.tabBarItem.image = [UIImage imageNamed:@"More.png"];
myAppDelegate.myTabBarController.viewControllers = [NSArray arrayWithObjects:tab1,tab2,tab3,tab4,nil];
[myAppDelegate.rootNav pushViewController:myAppDelegate.myTabBarController animated:YES];

在选项卡 4 中,我按 Profile_ViewController:

 Profile_ViewController *vc = [[Profile_ViewController alloc] initWithNibName:@"Profile_ViewController" bundle:[NSBundle mainBundle]];
 [self.navigationController pushViewController:vc animated:YES];

我已经在那里申请了:

myAppDelegate.myTabBarController.hidesBottomBarWhenPushed=NO; 
and 
[self.tabBarController setHidesBottomBarWhenPushed:NO];

在 Profile_ViewController 的 viewWillAppear 中。没有任何作用。我只看到一个空白的白色屏幕。

您可能保留了如下架构 导航控制器 ---> 标签栏控制器 --> 4 个子视图控制器

你需要这样做 选项卡栏控制器 --> 4 个子控制器(这 4 个子视图控制器中的每一个都有自己的导航控制器)。

location_select *tab1 = [[location_select alloc] initWithNibName:@"location_select" bundle:nil];
tab1.tabBarItem.image = [UIImage imageNamed:@"Restaurants.png"];
location_select *tab2 = [[location_select alloc] initWithNibName:@"location_select" bundle:nil];
tab2.title = @"Cart";
tab2.tabBarItem.image = [UIImage imageNamed:@"Cart.png"];
Deal_ViewController *tab3 = [[Deal_ViewController alloc] initWithNibName:@"Deal_ViewController" bundle:nil];
tab3.title = @"Deals";
tab3.tabBarItem.image = [UIImage imageNamed:@"Deals.png"];

MoreViewController *tab4 = [[MoreViewController alloc] initWithNibName:@"MoreViewController" bundle:nil];
tab4.title = @"More";
tab4.tabBarItem.image = [UIImage imageNamed:@"More.png"];




UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:tab1];

UINavigationController *nav2 = [[UINavigationController alloc] initWithRootViewController:tab2];

UINavigationController *nav3 = [[UINavigationController alloc] initWithRootViewController:tab3];

UINavigationController *nav4 = [[UINavigationController alloc] initWithRootViewController:tab4];

myAppDelegate.myTabBarController.viewControllers = [NSArray arrayWithObjects:nav1,nav2,nav3,nav4,nil];
[myAppDelegate.rootNav pushViewController:myAppDelegate.myTabBarController animated:YES];

and then later on to push your vc to tab 4 you should do

Profile_ViewController *vc = [[Profile_ViewController alloc] initWithNibName:@"Profile_ViewController" bundle:[NSBundle mainBundle]];
[nav4 pushViewController:vc animated:YES];

这是与您的查询相关的解决方案,可能会对您有所帮助