cheznead
cheznead

Reputation: 2779

How to set title of navigation bar in storyboard?

I can't solve this despite my best efforts. I also consulted the Apple documentation and several related questions here and still I have a mental block on this.

Using Xcode 6, I embedded a table view controller in a navigation controller and could set the title of the navigation bar in the table view controller, but not in the two view controllers that are connected to the table view via segues.

I did think there was a navigation bar on these two view controllers because after I embedded the table view controller in the navigation controller, it blocked out my topmost textfield in both. I repositioned that so that isn't a problem, but in storyboard I still don't seem to be able to click inside the navigation bar to add a title and now having added a navigation bar manually to test it out, I can see that there is only one navigation bar in document outline.

So do you simply have to set the title of the navigation bar programmatically or with an IBOutlet or some such? Doesn't seem like you can click into it in story board.

Upvotes: 21

Views: 23664

Answers (10)

rckehoe
rckehoe

Reputation: 1198

I am pretty sure this is a bug in Xcode... I have experienced the same issue and most of the time it was solved by restarting Xcode.

** In addition you may be able to get it solved by doing:

Drag a Navigation item from the objects pane into the viewcontroller or tableviewcontroller. This seemed to work for me. I did notice that the navigation area was missing from the "Document Outline Pane".

I hope this helps.

Upvotes: 32

sohelpme
sohelpme

Reputation: 145

You can also set the view controller's "title" property instead, which will automatically set the title of a navigation item or tab bar item.

By selecting the view controller in the storyboard, you can set the title under "View Controller" in the Attributes inspector (Xcode 9):

enter image description here

Upvotes: 2

Sentry.co
Sentry.co

Reputation: 5569

None of the answers worked for me.

This worked:

  1. Delete nav connection
  2. Ctrl drag a new nav connection
  3. Make it a show connection
  4. Now you can edit the title
  5. Delete the nav connection again
  6. Create the original nav connection type again

It seems that this is indeed a bug in IB 🙁

Upvotes: 1

tsson
tsson

Reputation: 121

I had the same problem while following apple's swift guid. Dubble-clicking the "navigation bar" did nothing for me. How I solved it:

1: Select the "navigation item" from the document outline pane.

2: Open the attributes-inspector.

3: Select the title field and write the title here instead.

Upvotes: 12

xxcat
xxcat

Reputation: 137

Update to this issue if someone else need it:

  1. Make a segue between ViewControllers
  2. Pick Kind option as Show(e. Push)
  3. Than change this Kind option on some deprecated - ex. Push
  4. Now you can edit your tittle and navigation items from storyboard
  5. Remember to change Kind option again on what you need.

Upvotes: 1

Ade
Ade

Reputation: 373

Connect your Navigation Item to your class (i.e. UIViewController), and access it's title programmatically by writing the following within your viewDidLoad:

navigationItem.title = "whateverTextHere"

Upvotes: 2

Dennis Hansen
Dennis Hansen

Reputation: 21

place this is your prepare for segue: [segue.destinationViewController setTitle:@"New Task"];

Upvotes: 2

Hutch
Hutch

Reputation: 854

I had the same problem. What worked for me was to select the controller that I couldn't set the title on, click editor -> embed in -> Navigation controller.

Then you should be able to edit the title and when finished, delete the navigation controller and reconnect the two original controllers.

The screen that was previously embedded should now contain the title you created earlier.

Upvotes: 6

kumpri
kumpri

Reputation: 11

Be sure to use a Relationship Segue, not a Manual Segue when embedding controllers.

Upvotes: 1

Yakir Sayada
Yakir Sayada

Reputation: 181

Try to set title programmatically -> self.navigationItem.title = @"REGISTER";

Upvotes: 5

Related Questions