在模拟器中,我设置了调试->位置->自定义位置纬度和经度。
然后在代码中我有:
- (void)updateMap{
MKCoordinateSpan span;
span.latitudeDelta = .6;//The amount of north-to-south distance (measured in degrees) to display on the map
span.longitudeDelta = .6;//The amount of east-to-west distance (measured in degrees) to display for the map region
MKCoordinateRegion region;
region.center = _ls.coordinate;
region.span = span;
[mapView setRegion:region animated:TRUE];
}
在另一个文件中,我获得 @property (nonatomic, readonly) CLLocationCoordinate2D 坐标;
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{
//Get the latitude and longitude location
CLLocation *lastLocation = [locations lastObject];
_latitude = [[NSString alloc] initWithFormat:@"%f", lastLocation.coordinate.latitude];
_longitude = [[NSString alloc] initWithFormat:@"%f", lastLocation.coordinate.longitude];
_coordinate = lastLocation.coordinate;//manager.location.coordinate;
}
当我运行该应用程序时,模拟器一直显示旧金山。任何想法为什么?