0
votes

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.

2
you mean you want to navigate your app to another viewCont from one of the 4 tab ?vaibhav
@jamshed Can you share more info on how your app is structured? Are you using a UINavigationController in your app?Shayan Jalil
can you Share the Storyboard Screenshot ??Pankaj Teckchandani
yes, want to navigate your app to another viewCont from one of the 4 tab. vaibhavJamshed Alam
no, may be problem with UINavigationController . Lets change it. Shayan JalilJamshed Alam

2 Answers

0
votes
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

0
votes

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).