0
我查看了現有的問題,並相信我遵循規則,但某些原因導致我的地圖不縮放。我已經放置了一個斷點,以確保我的座標正在通過,並且在那裏一切似乎都沒有問題。mapView不縮放到座標
以下是我的代碼。
- (void)viewDidLoad
{
[super viewDidLoad];
[self configureView];
mapView = [[MKMapView alloc]initWithFrame:CGRectMake(20, 20, 260, 169)];
mapView.delegate = self;
mapView.mapType = MKMapTypeStandard;
[self.view addSubview:mapView];
}
- (void)mapView:(MKMapView *)mapView regionWillChangeAnimated:(BOOL)animated {
Bar *maps = self.detailItem;
MKCoordinateSpan span;
span.latitudeDelta = .02;
span.longitudeDelta = .02;
CLLocationDegrees latDegree = [maps.barLat doubleValue];
CLLocationDegrees longDegree = [maps.barLong doubleValue];
CLLocationCoordinate2D location = CLLocationCoordinate2DMake(latDegree, longDegree);
MKCoordinateRegion region;
region.center = location;
region.span = span;
[mapView setRegion:region animated:TRUE];
}