Reputation: 2779
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
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
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):
Upvotes: 2
Reputation: 5569
It seems that this is indeed a bug in IB 🙁
Upvotes: 1
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
Reputation: 137
Update to this issue if someone else need it:
Upvotes: 1
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
Reputation: 21
place this is your prepare for segue: [segue.destinationViewController setTitle:@"New Task"];
Upvotes: 2
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
Reputation: 11
Be sure to use a Relationship Segue, not a Manual Segue when embedding controllers.
Upvotes: 1
Reputation: 181
Try to set title programmatically -> self.navigationItem.title = @"REGISTER";
Upvotes: 5