简体   繁体   中英

Different navigation item for each view in tab bar controller

The Problem

I'm relatively new to Swift and I'm trying to build an application that makes use of a UITabBarController.

What I'm trying to do is put a different navigation bar (or UINavigationItem ) on each of the tabs in the UITabBarController.

For example, I want the UINavigationItem I set, with its bar button items, to appear on MyViewController instead of a back button to the previous view controller, such as shown on the image below.

返回键

The current layout on the Storyboard is as follows.

故事板

MyViewController on the sidebar:

MyViewController的细目分类

What I've Tried

Someone suggested that I should embed each UIViewController (eg MyViewController) in a Navigation Controller. I've tried this and it doesn't work.

I've also tried to set the Top Bar to "None" in the Attributes tab of the options menu.

属性

Thank you in advance for your help.

Here is how i did it,

UINavigationController -> UITabbarController

And then each " Tab " is in different Storyboard and every storyboard start with a " Navigation Controller ". So yes every tab in different navigation controller this how you should do it.

Different storyboards because may be multiple people work on storyboard at same time.

Why TabbarController inside Navigationcontroller ?

I put the "TabbarController" inside "NavigationController" because some of the controllers i want them to be full screen, like hiding the "Tabbar" so for that i push them from main NavigationController.

//Out of context but may help you, I have created an "Extension" of Navigation Controller to push a view controller on main navigation so that any of the tabbars (which are also inside navigation controllers) can easily use the extension to push any view controller if want to hide the tabbar.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM