Connecting the outlets for the map view to MapViewController

The view controller scene for the Map screen displays a map, but there is currently no way to set the map region to be displayed and no way to display annotations. Let's assign MapViewController to the view controller for the Map screen in Main.storyboard and add an outlet for the map view to it. Do the following steps:

  1. Click Main.storyboardClick the View Controller icon in the View Controller Scene for the Map screen. In the Identity inspector, under Custom Class, select MapViewController in the Class drop-down menu:

  1. Select the Map View in the document outline:


  1. Click the Adjust Editor Options button:


  1. Choose Assistant in the pop-up menu:


  1. The assistant editor appears, showing the contents of MapViewController. Ctrl + Drag from the Map View to the space just under the class declaration:

  1. Type mapView in the Name field and click Connect:


  1.  The Map View has been connected to the mapView outlet in MapViewController. Click the x button to close the assistant editor:


MapViewController now has an outlet, mapView, that is linked to the map view in the Map screen. Next, you'll modify MapDataManager so it can provide a map region for the map view to display, by adding a method to generate a new region based on the restaurant's location.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.12.172