1

For better understanding I created a new project and broke down my issue.

Before, I had a Storyboard with a Main Menu and from there it is possible to jump to different Viewcontrollers. One of them is embedded in a TabBarController as shown in the image. enter image description here

To improve the structure, I have refactored the TabBarController to a second storyboard as shown in image2. But now I want to add some NavigationBar Items (Buttons). For each Tab I want to have a Button for some actions. Somehow the NavigationBar is gone now in the new Storyboard.

enter image description here

I have already found some suggestions in different Threads like iOS 8 Swift navigation bar title, buttons not showing in tab based application

From there I tried the code

let navigationBar = navigationController!.navigationBar
        navigationBar.tintColor = UIColor.green
        let rightButton = UIBarButtonItem(title: "Right Button", style: UIBarButtonItem.Style.plain, target: self, action: nil)

        navigationItem.rightBarButtonItem = rightButton

Which gives me a green Back Button, but the rightButton is not showing.

I have also tried embedding in a new NavigationController which just results in a double navigation... Also I tried to add just a NavigationBar manually, which also results in a double navigation as shown in the image below. enter image description here

Any ideas how I could solve this?

Flo
  • 79
  • 8

1 Answers1

0

I don't know if this is a good solution or not but it works for me.

Basically the code was correct

let navigationBar = navigationController!.navigationBar
navigationBar.tintColor = UIColor.green
let rightButton = UIBarButtonItem(title: "Right Button", style: UIBarButtonItem.Style.plain, target: self, action: nil)

self.navigationItem.rightBarButtonItem = rightButton

But it is necessary to add one thing to the code, adding parent solves my issue

self.parent!.navigationItem.rightBarButtonItem = rightButton
Flo
  • 79
  • 8