0

I have a TabBarController with 4 Tab. When i push a ViewController from a tab then the tab is hidden automatically and its showing nothing in View. But ViewController contains a tableview with data. I have implemented tableview delegate also.I am not getting tableview delegate logs.

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

Load TabBar here:

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

From Tab 4, i push Profile_ViewController:

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

And already i applied there:

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

in viewWillAppear of Profile_ViewController. Nothings works. I just see a blank white screen.

6
  • you mean you want to navigate your app to another viewCont from one of the 4 tab ?
    – vaibhav
    Sep 26, 2016 at 8:15
  • @jamshed Can you share more info on how your app is structured? Are you using a UINavigationController in your app? Sep 26, 2016 at 8:16
  • can you Share the Storyboard Screenshot ?? Sep 26, 2016 at 8:33
  • yes, want to navigate your app to another viewCont from one of the 4 tab. vaibhav Sep 26, 2016 at 8:47
  • no, may be problem with UINavigationController . Lets change it. Shayan Jalil Sep 26, 2016 at 8:48

2 Answers 2

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

here is the Solution related to your query which might help you

2
  • Yes. I already did that. I just forgot that i faced same issue 2years ago. Whatever, thanks for your effort. Sep 26, 2016 at 12:17
  • All the best :) Sep 27, 2016 at 10:04
0

You might have kept your architecture as follows Navigation Controller ---> Tab bar Controller --> 4 child View Controllers

You need to do this Tab bar Controller --> 4 Child controllers(Each of these 4 child View Controller having its own Navigation Controller).

2
  • Added it already. Not working. Tab bar hide still. But i am getting my pushed screen. Sep 26, 2016 at 9:30
  • No you are not, your current Architecture has only one navigation controller. i am saying you should have 4 Different Navigation Controllers.(One navigation controller each for all your 4 view controllers) Sep 26, 2016 at 9:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.