Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 904
cheznead Avatar asked Oct 25 '14 16:10

cheznead


People also ask

How do you add a title to a storyboard?

Add a title layout to a storyboard project clipTap the Edit button to the right of the clip, then tap Edit Clip. Tap the clip, then tap the Titles button at the bottom of the screen. Tap a title layout, then tap Done.

How do I customize my navigation bar?

From Settings, tap Display, and then tap Navigation bar. Make sure Buttons is selected, and then you can choose your desired button setup at the bottom of the screen. Note: This option will also affect the location you swipe when using Swipe gestures.

How do I customize the navigation bar title in SwiftUI?

To customize a navigation bar title view in SwiftUI, we simply set ToolbarItem of placement type . principal to a new . toolbar modifier.


3 Answers

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.

like image 117
rckehoe Avatar answered Oct 11 '22 01:10

rckehoe


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.

like image 12
tsson Avatar answered Oct 11 '22 01:10

tsson


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.

like image 6
Hutch Avatar answered Oct 11 '22 02:10

Hutch