How to set the title of a Navigation Bar programmatically?

I have a Navigation Bar in a view, and I want to change its Navigation Item title programmatically.

How is this done?


Solution 1:

In your UIViewController

self.navigationItem.title = @"The title";

Solution 2:

Swift 3 Version:

If you use a navigation bar without navigation controller, then you can try this:

navigationBar.topItem?.title = "Your Title"

Hope for help.

Solution 3:

In viewDidLoad

  self.title = @"Title";