Connecting Navigation Controller to View controller

I am trying to learn Xcode using iOS 14 Programming for Beginners.
I some how made an error when working through the instructions in the book. There are 2 navigation controllers and I connected a view controller to the wrong Navigation controller. When I realised my mistake I deleted the segue between the wrong Navigation Controller and the view controller. I then Ctrl + Dragged from the correct Nav Controller to the view controller and then created a new View Controller and did the same to this controller to the other Nav controller.
If I build the app every thing seems to work, except the Nav controller does not load the Map view when I click on the map icon, even though I have added the Map View to the View Controller.
Please help?
Answered by Claude31 in 675931022
You need to connect with a Relationship segue.
  • Control drag from the root to the next VC and use relationship segue (root view controller) from the Navigation controller to the top VC in the navigation stack.

  • And don't forget to do an option-clean build Folder.


If that doesn't work:
You said in initial post:

except the Nav controller does not load the Map view when I click on the map icon, even though I have added the Map View to the View Controller.

Where is this map icon ?
Is it a button in a tab bar ?
What is the ViewController that contains the map ?

You may have to explain more precisely your set up.
such as:
Nav A -> VC A
Nav B -> VC B
VC B contains map button (where ? In tab bar, directly in the view ?)
button segues to VC C
VC C contains a mapView
I have noticed that the segue icon is incorrect as I added a new View Controller and linked as I explained in the first post. I used Show but it should be an icon with a diagonal line with 2 dots at each end. Not sure what that is, but guess its the icon for a Tab Bar branch.
Accepted Answer
You need to connect with a Relationship segue.
  • Control drag from the root to the next VC and use relationship segue (root view controller) from the Navigation controller to the top VC in the navigation stack.

  • And don't forget to do an option-clean build Folder.


If that doesn't work:
You said in initial post:

except the Nav controller does not load the Map view when I click on the map icon, even though I have added the Map View to the View Controller.

Where is this map icon ?
Is it a button in a tab bar ?
What is the ViewController that contains the map ?

You may have to explain more precisely your set up.
such as:
Nav A -> VC A
Nav B -> VC B
VC B contains map button (where ? In tab bar, directly in the view ?)
button segues to VC C
VC C contains a mapView

Thank you that worked!

Connecting Navigation Controller to View controller
 
 
Q