MKMapView crash on LandscapeRight

I have made an app in Swift targeting all iPhone/iPad versions iOS level 8.0+, and have encountered a severe problem.


This happens on iOS 9.2, also in the simulator (using xcode 7.2). I have tested on iOS 8.1 (both simulators and an iPhone 4s) and it works OK.

The app consists of a main viewcontroller with a MKMapView filling the entire view (with some buttons on top).


When I rotate the device to the left (to LandscapeRight), the mapview turns grey and does not load the map. (All the buttons on top of the mapview appear correctly) I have done some debugging, and the mapView.centerCoordinate is (nan, nan) so it is a bug in the mapview somewhere.


This is rather bad, as rotating back to another orientation does not help and the app must be forcefully terminated to recover.

Before rotating to LandscapeRight, I can rotate to other interface orientations (including LandscapeLeft) and it is working fine.


It may be device specific, it seems to work on my iPhone 6 (iOS 9.2.1), but crashes on all simulators (9.2) and my iPad Air2 (also 9.2.1)


I don't know if this is a known problem, but I have seen there have been some rotation bugs earlier so this may be related.


Is there a way around this? Is there a fix available? The only solution I have found is to disable LandscapeRight


Thanks

OK, managed to locate the problem (based on some discussions on previous map rotation errors). It was related to a wrong UI constraint

Superview.bottomMargin = mapview.bottom - 6


This caused the mapview to get wrong values when rotating to LandscapeRight, and being unable to recover.


I fixed it by setting bottom layout guide = mapview bottom


I would still call this a bug that should probably be fixed though. Certainly caused me som extra work


Regards

MKMapView crash on LandscapeRight
 
 
Q