在ios5.0中下面的代碼運行正確:
self.mapView = [[[MKMapView alloc]init] autorelease];
mapView.delegate = self;
mapView.frame = CGRectMake(0, 0, 320, 414);
[myView addSubview:mapView];
MKCoordinateRegion zoomRegion = MKCoordinateRegionForMapRect(MKMapRectWorld);
MKCoordinateRegion adjustedRegion = [mapView regionThatFits:zoomRegion];
[mapView setRegion:adjustedRegion animated:NO];
然後我在iphone6.0中運行,就會在[mapView setRegion:adjustedRegion animated:NO];
這個地方崩潰。
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: 'Invalid Region <center:+0.00000000, +0.00000000 span:+176.06470039, +360.00004292>'
應該怎麼辦呢?謝謝。
看起來是[mapView regionThatFits:zoomRegion];
引起的問題,刪了它 :
MKCoordinateRegion zoomRegion = MKCoordinateRegionForMapRect(MKMapRectWorld);
// MKCoordinateRegion adjustedRegion = [self.mapView regionThatFits:zoomRegion];
[self.mapView setRegion:zoomRegion animated:NO];