2016-09-26 86 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個視圖控制器) –