Using UITabBarController with UINavigationController - Swift 3

不羁的心 提交于 2019-12-09 03:59:52

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/41567013/using-uitabbarcontroller-with-uinavigationcontroller-swift-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!