Creating and adding annotations
Now, we need to get our Map hooked up and start getting the annotations displaying on the Map. Then, we will customize our annotations to look like those in our design.
Creating our Map View Controller
We need to create our Map View Controller file and then connect it with our UIViewController and Map View in Storyboard. First, let's create this file:
In the Navigator panel, right-click on the
Controller
folder in theMap
folder and select New File.Inside of the Choose a template for your new file screen, select iOS at the top and then Cocoa Touch Class. Then, hit Next.
Add the following into the options screen that appears:
New File:
Class:
MapViewController
Subclass…:
UIViewController
Also create XIB: Unchecked
Language:
Swift
Click on Next and then Create.
Under the import
UIKit
statement, addimport MapKit
.Update your class declaration to include the following subclass:
class MapViewController: UIViewController, MKMapViewDelegate
Let's now connect this file with our...