I used the code below before iOS 10 (e.g. iOS 9.3) to get user location successfully.
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
[self.locationManager requestWhenInUseAuthorization];
[self.locationManager startUpdatingLocation];
CLLocationCoordinate2D noLocation;
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(noLocation, 20000, 20000);
MKCoordinateRegion adjustedRegion = [self.mapView regionThatFits:viewRegion];
[self.mapView setRegion:adjustedRegion animated:YES];
self.mapView.showsUserLocation = YES;The above code crashes on iOS 10 with the following log:
2016-08-08 01:31:07.211 EMOS1iOS[3019:181508] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid Region <center:-180.00000000, -180.00000000 span:nan, nan>'
*** First throw call stack:
(
0 CoreFoundation 0x000000010a12ca0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x0000000109b8e21e objc_exception_throw + 48
2 CoreFoundation 0x000000010a12c959 -[NSException raise] + 9
3 MapKit 0x0000000108ec28bc -[MKMapView setRegion:animated:] + 705
4 MyApp 0x0000000108a189a7 -[MapViewController viewDidLoad] + 887
5 UIKit 0x000000010b163269 -[UIViewController loadViewIfRequired] + 1258I have fixed the issue by setting noLocation as below:
CLLocation *location = [self.locationManager location];
CLLocationCoordinate2D noLocation = [location coordinate];Is this a iOS 10 beta 4 bug or is it an erroneous implementation from my side?