Views are not created programmatically

After following the book, I can’t even create views programmatically with overriding viewLoad().

  1. deleted Map View on storyboard.
  2. amended MapViewController with overriding loadView() and setting view = mapView

However when I build and run the application, only Convert tab is showing and Map tab is not showing up at all. Please help, I can’t even follow the book any further without achieving this.

import UIKit
import MapKit

class MapViewController: UIViewController {

var mapView: MKMapView!

override func loadView() {
    mapView = MKMapView()
    view = mapView
}

override func viewDidLoad() {
    super.viewDidLoad()
    print("MapViewController loaded its view")
}

}

1 Like

This is now resolved - not that anybody replied. Apparently, I had deleted Map View Controller on storyboard, rather than Map View only.

1 Like

Thanks for sharing. I struggled with this one, too. I glossed over fig 6.2 and had to go back and recreate ch.5.

@Hugo.Z.Hackenbush

Had similar problem with this one as well, followed your lead and recreated. (It works!)