Setting title of UINavigationbar not working

懵懂的女人 提交于 2019-12-02 11:53:08

First of all in your storyboard select your view controller and then

Editor -> Embed In -> Navigation Controller

then in your ViewController class add

self.title = "AAA"

in your viewDidLoad method and your code will look like:

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "AAA"
    }
}

You need to replace UINavigationController with UIViewController

Select ViewController from the storyboard.

Go to the Editor and Embed with Navigation Controller

1) Select Navigation Item and set title from the storyboard.

2) By Programmatically

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "Your Title"
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!