2013-11-14 179 views
0

註釋查看氣泡大小太小9次滿10次。 我打電話[self.mapView selectAnnotation:self.selectedVenue animated:YES];選擇一行時顯示註釋視圖。我是否設置了animated:YESNO它仍然顯示錯誤的大小。不過,如果我將地圖視圖高度的大小增加到200像素,除了地圖視圖對於3.5英寸屏幕太大,一切看起來都不錯。標題和副標題正確MKPinAnnotationView無法正常顯示

圖片:。https://dl.dropboxusercontent.com/u/5105730/anno.png

以下是我創造我的註解視圖

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation{ 

if ([annotation isKindOfClass:[FSVenue class]]) { 
    static NSString *PlaceAnnotationIdentifier = @"Place Identifier"; 

    MKPinAnnotationView *annotationView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:PlaceAnnotationIdentifier]; 

    if (annotationView == nil) { 
     annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:PlaceAnnotationIdentifier]; 
    } 

    annotationView.annotation = annotation; 

    UIButton *calloutButton = [UIButton buttonWithType:(UIButtonTypeContactAdd)]; 
    calloutButton.tintColor = self.themeColor; 

    annotationView.enabled = YES; 
    annotationView.pinColor = MKPinAnnotationColorGreen; 
    annotationView.canShowCallout = YES; 
    annotationView.rightCalloutAccessoryView = calloutButton; 
    annotationView.animatesDrop = YES; 

    return annotationView; 
} 

return nil; 

}

回答

0

您必須在添加您的註釋之後縮放您的mapview的可視矩形。

[self.yourMapview addAnnotations:self.yourAnnotationsArray]; 
[self zoomToAnnotations]; 

呼叫加入您的註解這樣

-(void)zoomToAnnotations{ 

    MKMapRect zoomRect = MKMapRectNull; 

    for (_yourAnnotation in self.yourMapView.annotations) { 
     MKMapPoint annotationPoint = MKMapPointForCoordinate(_yourAnnotation.coordinate); 
     MKMapRect pointRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, 0.1, 0.1); 
     if (MKMapRectIsNull(zoomRect)) { 
      zoomRect = pointRect; 
     }else{ 
      zoomRect = MKMapRectUnion(zoomRect, pointRect); 
     } 
    } 
    if (zoomRect.size.width == 0.10) /* for single annotation available in map */ 
    { 
     zoomRect = MKMapRectMake(zoomRect.origin.x, zoomRect.origin.y, 100000, 100000); 
    } 

    [[self yourMapView] setVisibleMapRect:zoomRect edgePadding:UIEdgeInsetsMake(50, 50, 50, 50) animated:YES]; 

} 
後,這種方法