--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.
<I had exactly same problem, spent a lot of time to find a solution and finally I did. So in my case problem was with wrong inisializing. Usually you would write let mapView = MKMapView() on the top of the viewController and then customise it somewhere later inside viewDidLoad but after IOS 11 Beta 1 it stopped working. I fixed it by changing to var mapView: MKMapView? on the top of the viewController and then inside viewDidLoad I inisializ it like mapView = MKMapView(). Hope it helps someone! :)
I Think you should try By removing
- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
}
and Putting following code into your View Didload Method
CGFloat edge = 10.0f;
UIImage *gotoUserLocationButtonImage = self.gotoUserLocationButton.imageView.image;
self.gotoUserLocationButton.frame = CGRectMake(edge, edge + self.statusBarHeight, gotoUserLocationButtonImage.size.width, gotoUserLocationButtonImage.size.height);
UIImage *getDirectionsButtonImage = self.getDirectionsButton.imageView.image;
[self.getDirectionsButton setFrame:CGRectMake(CGRectGetMaxX(self.gotoUserLocationButton.frame), edge + self.statusBarHeight, getDirectionsButtonImage.size.width, getDirectionsButtonImage.size.height)];
Make sure you are not using dispatch_async for the map.
I had the following function that did not work in iOS11
dispatch_async(dispatch_get_main_queue(), ^{
@synchronized(_queue) {
if(poppedMapView != nil) {
[self.queue removeObject:poppedMapView];
}
[self.queue addObject:[[MKMapView alloc] init]];
}
});
Changed it to
if(poppedMapView != nil) {
[self.queue removeObject:poppedMapView];
}
[self.queue addObject:[[MKMapView alloc] init]];
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()
}