0

Show TabBarController are user navigation from another UIViewController.

UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
CategoryViewController *categoryViewController = [storyBoard instantiateViewControllerWithIdentifier:@"CategoryViewController"];
[self.tabBarController.navigationController pushViewController:categoryViewController animated:YES];

After navigating from UITabBarController to another UIViewController class i.e., CategoryViewController the tabbarcontroller disappears, I want to show the UITabBarController even its navigate to another controller.

Anurag Sharma
  • 4,276
  • 2
  • 28
  • 44
kiran
  • 4,285
  • 7
  • 53
  • 98

1 Answers1

-1

You are pushing your Next view controller at the place of your tabbar

[self.tabBarController.navigationController pushViewController:categoryViewController animated:YES];

The above line will push your next view controller.

To resolve the issue you have to embed your current view controller (Which is being displayed in selected tab) in navigation controller and use

[self.navigationController pushViewController:YOUR_VIEWCONTROLLER animated:YES];
Devang Tandel
  • 2,988
  • 1
  • 21
  • 43
  • you need to understand that the `navigationController` has the `tabBar` so make sure you test your code before posting! – Anurag Sharma Aug 08 '17 at 13:29
  • 1
    @AnuragSharma - Read the lines above the code. The current view controller from which he is pushing to next view controller i told him to embed in navigation controller. – Devang Tandel Aug 08 '17 at 13:33
  • 1
    so [self.navigationController ] will refer to navigation controller in which the current view controller is not the navigation controller of tabbar. – Devang Tandel Aug 08 '17 at 13:34
  • 1
    read the description too before down voting or commenting. use your mind little bit. – Devang Tandel Aug 08 '17 at 13:35
  • have a [look here](https://stackoverflow.com/questions/9936114/how-to-push-additional-view-controllers-onto-navigationcontroller-but-keep-the-t) and thank me later! – Anurag Sharma Aug 08 '17 at 13:36
  • 1
    Down voters feel free to comment. What is wrong in the answer – Devang Tandel Aug 08 '17 at 13:41
  • @Dev_Tandel You are correct in your case! If TabBarController will seuge with nagivationcontroler and navigationController not be part or rootviewcontroller then it will not show TabbarController. – kiran Aug 09 '17 at 09:57
  • Yes , this why i mentioned in my answer : To resolve the issue you have to embed your current view controller (Which is being displayed in selected tab) in navigation controller – Devang Tandel Aug 09 '17 at 10:06
  • Thank you though, you have post your view on your vote. – Devang Tandel Aug 09 '17 at 10:08