0

I am making an app which requires a use of a UITabBarController along with UINavigationController. I have made the following flow in storyboard.

See image

Now the first question is that is this accepted by Apple, as there are too many discussions for the same.

The other matter of concern is that is it possible to eliminate any UINavigationController and still get the same flow of the app? The main thing required is to have the SAME tab bar and navigation bar on all sub tabs of the tabs. One point to be noted is that if I remove the second UINavigationController then my app navigates directly from sub tab to home view controller on clicking back button.

I have been stuck on this since hours now. I am new to iOS app development and have never uploaded any app to the app store. Any help would greatly valued.

EDIT :

I put the second navigation controller as shown in the answers - see this flow, But because I have a navigation controller before the HomeViewController, so I am getting a navigation bar at the top and then some empty space below that(exactly equal to the top navigation bar) and then the page contents on runtime. Any solution to this?

Dia
  • 237
  • 7
  • 17
  • this drawers... only way is to use one main view with tabbar in container and that drawer, navigation etc on top. And again why apple could possibly not accept app? O.o – Lu_ Jan 10 '17 at 10:55
  • Check http://stackoverflow.com/questions/27422054/how-to-implement-tab-bar-controller-with-navigation-controller-in-right-way – Avijit Nagare Jan 10 '17 at 11:04
  • @AvijitNagare Thanks for the link :) – Dia Jan 10 '17 at 12:17
  • @AvijitNagare I did the same as shown in link but because I have a navigation controller before the HomeViewContreoller, so i am getting a navigation bar at the top and then some empty space below that(exactly equal to the top navigation bar) and then the page contents on runtime. Any solution to this? – Dia Jan 10 '17 at 12:23
  • Yes, correct. it will remain same when you embed into NavC. you can set it to none from attribute inspector by selecting NavC. or hide by programatically. or try for custom navigation library. – Avijit Nagare Jan 10 '17 at 15:11
  • @AvijitNagare I tried setting none the second navigation controller but then the navigation bar back button from the sub tab takes me directly to the home view controller – Dia Jan 10 '17 at 15:34
  • Dont push tab bar controller from HomeViewController. either [self presentviewcontroller] or [self setViewController:tabViewController] – Avijit Nagare Jan 10 '17 at 15:57
  • I didn't understand what you mean by this – Dia Jan 10 '17 at 16:00

2 Answers2

0

Yes, it is acceptable by Apple.

But View hierarchy is not managed correctly. In your case Tab bar will be the root view controller for 2nd navigation controller.

Also, Tab and sub tab you are pushing will be part of 2nd navigation controller.

That's the reason you are getting back on Home view controller.

It's good practice to keep navigation controller to each Tab to manage it's sub-tab hierarchy.

You could present tab bar controller or setviewcontroller from Home View controller.

Avijit Nagare
  • 8,482
  • 7
  • 39
  • 68
  • so you mean the flow will be like tab bar controller > navigation controller > tab1; same tab bar controller > other navigation controller > tab2 ,and so on? – Dia Jan 10 '17 at 12:14
  • @user7205816. correct. so each tab nav. con. will manage its own stack. – Avijit Nagare Jan 10 '17 at 14:43
  • But I am getting empty space below navigation bar (see edited question), and if i set the second navigation controller's bar to none then when we click on back button from sub tab it jumps to home view controller – Dia Jan 10 '17 at 15:38
0

First embed tab bar controller as in this imageenter image description here and the embed navigation bar controller as in this image enter image description here finally this will look like enter image description here

  • but in this case i will need to embed navigation controller in all the 4 tabcontroller pages right? – Dia Jan 10 '17 at 12:11
  • I did the same as shown by you but because I have a navigation controller before the HomeViewContreoller, so i am getting a navigation bar at the top and then some empty space below that(exactly equal to the top navigation bar) and then the page contents on runtime. Any solution to this? – Dia Jan 10 '17 at 12:22
  • But I am getting empty space below navigation bar (see edited question), and if i set the second navigation controller's bar to none then when we click on back button from sub tab it jumps to home view controller – Dia Jan 10 '17 at 15:38