2016-09-26 85 views
0

我有一个TabBarController与4选项卡。当我从一个标签中推一个ViewController时,该标签会自动隐藏,并且它在View中什么都不显示。但ViewController包含一个包含数据的表格视图。我也实现了tableview委托。我没有得到tableview委托日志。iOS 9.0 Tabbar自动隐藏和viewcontroller消失在推

中的appdelegate didFinishLaunchingWithOptions()

self.window = [[ALLOC的UIWindow] initWithFrame:方法[[UIScreen mainScreen]界限]];

负载的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中。没有任何作品。我只看到一个空白的白色屏幕。

+0

你的意思是你想你的应用程序从4选项卡上的一个导航到另一个viewCont? – vaibhav

+0

@jamshed你可以分享更多关于你的应用程序结构的信息吗?你在你的应用中使用UINavigationController吗? –

+0

你能分享故事板截图吗? –

回答

0
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]; 

这里是解决方案与您的查询这可能会帮助你

+0

是的。我已经这样做了。我只是忘记了两年前我面临同样的问题。无论如何,谢谢你的努力。 –

+0

一切顺利:) –

0

你可能会一直保持你的架构如下 导航控制器--->标签栏控制器 - > 4子视图控制器

你需要这样做 标签栏控制器 - > 4个控制器(每这4个子View Controller有自己的导航控制器)。

+0

已经添加了。不工作。标签栏仍然隐藏。但我得到我的推动屏幕。 –

+0

不,您目前的架构只有一个导航控制器。 我在说你应该有4个不同的导航控制器(每个导航控制器对应所有4个视图控制器) –