Reputation: 589
I am trying to add text to the top bar in my view controller. The view controller is connected to a TabBarController.
This is how i set my view controllers options:
And this is the view controllers code:
override func viewDidAppear(animated: Bool) {
println("viewDidAppear")
self.tabBarItem.title = "Title"
self.tabBarController?.selectedViewController?.title = "Title"
self.tabBarController?.title = "Title"
}
I have tried all those and none of them works..
And this is how it looks like in the storyboard:
As you can see, what i want it to add text to the top of the view controller.
Upvotes: 1
Views: 480
Reputation: 2221
When you have your Viewcontroller embedded in NavigationBar then you can do this in viewWillAppear
self.title = "My Title"
Upvotes: 0
Reputation: 589
I got something working now. I dragged in a "Navigation Bar", and now it works.
Upvotes: 0
Reputation: 610
You will have a UINavigationItem in your view controller in storyboard, If not you can embed in and You just have to set the title of of navigationItem either from storyboard or in viewDidLoad() or viewDidAppear()
override func viewDidAppear(animated: Bool) {
println("viewDidAppear")
self.navigationItem.title = "Title"
}
Upvotes: 3