我正在使用这个方法获取用户位置
/*Region and Zoom*/
MKCoordinateRegion region;
MKCoordinateSpan span;
span.latitudeDelta=0.2;
span.longitudeDelta=0.2;
CLLocation *location1 = [locationManager location];
CLLocationCoordinate2D location = [location1 coordinate];
location.latitude = location.latitude;
location.longitude = location.longitude;
region.span=span;
region.center = location;
/*Geocoder Stuff*/
MKReverseGeocoder *geoCoder=[[MKReverseGeocoder alloc] initWithCoordinate:location];
geoCoder.delegate = self;
[geoCoder start];
mapView.showsUserLocation = TRUE;
[mapView setRegion:region animated:TRUE];
[mapView regionThatFits:region];
这段代码在实际运行中表现良好,但是当我尝试在模拟器中运行时,它会在[mapView setRegion:region animated:TRUE];
处崩溃,这表明它无法获取纬度和经度值。那么我该如何使这段代码在模拟器上运行良好呢?
我必须让这段代码在模拟器上运行,这是否可能?