Felix. v. O.
Felix. v. O.

Reputation: 23

How to show the ViewController's title while using Tab Bar?

I'm trying develop a simple internet radio app for iOS in Swift with the storyboard editor. I'm new to the iOS-App-Development, so if use wrong words for my problem, I apologise.

I want to show the title of a view controller while using a Tab Bar for switching between the different ViewControllers.

In the past I tried to find an option for showing the title bar (?) in the attributes inspector and I also tried some code for setting the title programmatically. In storyboard mode it seems to work, but when I run the app, the bar is hidden.

I searched a long time for a solution, but actually I don't get it to work...

Upvotes: 1

Views: 187

Answers (1)

Razi Tiwana
Razi Tiwana

Reputation: 1435

You have to Embed the ViewController in a UINavigationController

You can either do that via Storyboard

  • Select The controller in the Storyboard
  • Select -> Editor (top menu bar)
  • Select Embed In -> UINavigationController

Or if you are doing this programmatically you can

let navigationController = UINavigationController(rootViewController: viewController)

where viewController is your current visible controller.

Upvotes: 1

Related Questions