I'm trying to create a map programmatically but all I get is a black screen once I run the app.
Re page 97 in the Big Nerd Ranch iOS Programming 5th Edition, in chapter 6 'Creating a View Programmatically'
I entered the following code in MapViewController.swift
// MapViewController.swift
import UIKit
import MapKit
// Define a UIViewController subclass named MapViewController
class MapViewController: UIViewController {
var mapView: MKMapView!
override func loadView() {
// create a map view
mapView = MKMapView()
// set it as *the* view of this view controller
view = mapView
}
override func viewDidLoad() {
// Always call the super implementation of viewDidLoad
super.viewDidLoad()
print("MapViewController loaded its view.")
}
}
Once I run the app I get a black screen where the map should be. What's going wrong?
Thanks!