Going to the supermarket
Now, it is time to create the last scene of the iOS app. Here, we just need to add a new view controller with a label, map view, table view, and button to the storyboard.
A label is used only to display the scene's title. Therefore, we will set its title to Supermarket Directions
and place it at the top of the screen. Then, we will place the map under it to occupy approximately half the screen. Below the map, we will place the table view; here is where will display the directions. Lastly, we will place the button with the Main Menu
title. The final layout should be similar to the following screenshot:
Add a new file to your project called MapViewController.swift
and import the UIKit
, MapKit
, and CoreLocation
frameworks with the following code:
import UIKit import MapKit import CoreLocation
Create the corresponding class by calling it MapViewController
, inheriting from UIViewController
and implementing the MKMapViewDelegate
and UITableViewDataSource
protocols:
class MapViewController...