0
hy guys。如果你願意,我需要一些幫助。當我按下地圖按鈕時,我通過CLLocation屬性加載了一個具有經度和緯度的對象。事情是,我不希望地圖設置區域/中心座標到用戶位置,我希望地圖加載後它去的註釋區域,所以我這樣做:MKMapView setRegion to Annotation
- (void)loadActiveEstateAnnotation
{
RE_Annotation *re_annotation = [[RE_Annotation alloc] init];
if(self.mapView.showsUserLocation == YES)
NSLog(@"Santa Clause is comming to town");
re_annotation.longitude = viewingEstate.estateLocation.coordinate.longitude;
re_annotation.latitude = viewingEstate.estateLocation.coordinate.latitude;
re_annotation.poiID = [[RE_Shared sharedInstance] selectedEstate];
re_annotation.title = [NSString stringWithFormat:@"Estate %d",re_annotation.poiID];
[self.mapView addAnnotation:re_annotation];
CLLocationCoordinate2D activeAnnotationCoordonate;
activeAnnotationCoordonate.longitude = re_annotation.longitude;
activeAnnotationCoordonate.latitude = re_annotation.latitude;
MKCoordinateSpan activeEstateSpan;
activeEstateSpan.longitudeDelta = 0.05;
activeEstateSpan.latitudeDelta = 0.05;
MKCoordinateRegion activeEstateRegion;
activeEstateRegion.center = activeAnnotationCoordonate;
activeEstateRegion.span = activeEstateSpan;
NSLog(@"----These are the coordinates%f,%f", activeAnnotationCoordonate.longitude, activeAnnotationCoordonate.latitude); // coordinates are good and valid ive checked them
[self.mapView setRegion:activeEstateRegion];
[self.mapView regionThatFits:activeEstateRegion];
[re_annotation autorelease];
}
所以底線mapview outlet不會設置該區域,即使強硬的座標也沒問題。但它確實接受我給出的不同跨度,但仍然始終鎖定在用戶區域上;問題是...爲什麼?