annotationView气泡尺寸太小了10次。
我选择一行时调用[self.mapView selectAnnotation:self.selectedVenue animated:YES];
来显示注释视图。无论我设置animated:
YES
还是NO
,它仍然显示错误的大小。但是,如果我将地图视图高度的大小增加到至少200像素,一切看起来都不错,除了地图视图对于3.5英寸屏幕来说太大了。
我希望地图视图为此尺寸和注释气泡,以正确覆盖标题和副标题。
图片: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 :(得分:0)
添加这样的注释后,您必须缩放地图视图的可见矩形。
[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];
}