Navigation Bar Troubleshooting

I am using XCODE version 10.3. I have set up an single page application template:



First I embed the empty ViewController in a Navigation Controller using the embed button in the lower right hand corner of the XCODE GUI. Next I selected the canvas of the root view and used in object insert button to drag out a navigation bar into the root view's canvas and changed the title to "Hello World!".


When I run the app on a physical device I noticed that the navigation bar will appear with the title text "Hello World!" only for a second or two and then it will disappear and the only thing left showing will be a blank white canvas again as shewn also occuring in a simulated ipad 3rd generation device.


Also I would like to know how to obtain a reference object that becomes a member object of ViewController to the Navigation Bar UI element thats inserted and also I would like to find out why it disappears after about two seconds. I tried setting the deployment target between 12.3 and 12.4 but neither seemed to turn on solid the Navigation Bar UI element.

Also I tried dragging from the object insert button while the Navigation Bar area was selected in the storyboard editor and I tried dragging from the object insert button into the navigation bar area a new navigation item but nothing seems to show up anyplace. Only the title seems to show up and then disappears quickly.


Is it possible that there might be steps to get a reference object (or outlet?) to the navigation bar set up in the ViewController.swift thats autogenerated and also insert some items into the navigation bar either programmatically or by way of the object insert button?


Thank You!

Answered by eaeamending in 374574022

It is best described by Wallace Wang in his iOS for beginners swift 5 for that version of Xcode. His table view example can be embedded directly with the embed button but I would imagine the code can also be adapted to the drag and drop navigation controller in 10.3

I am using XCODE version 10.3. I have set up an single page application template:


Do you mean single View App ?


Next I selected the canvas of the root view and used in object insert button to drag out a navigation bar into the root view's canvas and changed the title to "Hello World!".


I did the same, and it works in simulator

Where did you drag the navBar ?

It must be under the area of the Navigation controller navbar, othjerwise it will be hidden.


But why do you create a new navbar ?


Is it possible that there might be steps to get a reference object (or outlet?) to the navigation bar set up in the ViewController.swift thats autogenerated and also insert some items into the navigation bar either programmatically or by way of the object insert button?


If you drag a Navigation controller in Interface Builder from the objects to the storyboard, you will get this: a Navigation controller and a TableViewController.

I had meant a single view app. Thank you for clarifying. It appears that there was an existing navbar as part of the navigation controller that was created with embed in navigation controller button on the now root view.


I was curious why holding the control key and dragging the navigation bar into ViewController.swift controller file isnt working. As well navigation bar items do not seem to be able to be added to that existing navigation bar via GUI object inserter.


Also is it documented where to set up a NavigationBar.swift controller file that is linked to the existing Navigation Bar as part of the existing navigation controller that was created with emed in navigation controller button while the now root view was selected.


Very little seems to be working like the documentation I read says that it should.


My questions about how to get a reference to the navigation bar, how to set up a navigation controller if thats possible and why control dragging into the viewcontroller didn't work are still not answered


Thanks!


P.S. I was thinking that:

https://code.tutsplus.com/tutorials/ios-from-scratch-with-swift-navigation-controllers-and-view-controller-hierarchies--cms-25462



repository might be answer to my question.

Accepted Answer

It is best described by Wallace Wang in his iOS for beginners swift 5 for that version of Xcode. His table view example can be embedded directly with the embed button but I would imagine the code can also be adapted to the drag and drop navigation controller in 10.3

Looking at the screenshots, it seems that VC are defined in launchScreen storyboard, not mainStoryboard. Was it the case ?

Navigation Bar Troubleshooting
 
 
Q