--Updated with new findings -- Tested in both simulator and on device. Maps are not loaded correctly when the app is run from a cold start. Tiles are not being displayed.
<
Had same problem my BROKEN code looked something like:
class ViewController: UIViewController {
fileprivate var mapView = MKMapView()
override func viewDidLoad() {
super.viewDidLoad()
// Add the mapView to the VC
mapView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(mapView)
mapView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true
mapView.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true
mapView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
mapView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
}
}
As it turned out in iOS 11 it does not like having the MKMapView initialize before the view controller has loaded ie viewDidLoad() so FIX was changing to:
class ViewController: UIViewController {
fileprivate var mapView: CSMapView?
override func viewDidLoad() {
super.viewDidLoad()
// Init instance here.
mapView = CSMapView()
// Add the mapView to the VC
mapView?.translatesAutoresizingMaskIntoConstraints = false
...
}
}
Also tried putting it in init methods but this DID NOT work for me:
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
mapView = MKMapView()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
mapView = MKMapView()
}