+ (MultiRowCalloutAnnotationView *)calloutWithAnnotation:(id<MultiRowAnnotationProtocol>)annotation onCalloutAccessoryTapped:(MultiRowAccessoryTappedBlock)block {
return [[[MultiRowCalloutAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:MultiRowCalloutReuseIdentifier onCalloutAccessoryTapped:block] autorelease];
}
- (id)initWithAnnotation:(id<MultiRowAnnotationProtocol>)annotation reuseIdentifier:(NSString *)reuseIdentifier onCalloutAccessoryTapped:(MultiRowAccessoryTappedBlock)block {
self = [super initWithAnnotation:(id<MKAnnotation>)annotation reuseIdentifier:reuseIdentifier];
if (self) {
self.contentHeight = 80.0;
_yShadowOffset = 6;
self.offsetFromParent = CGPointMake(8, -14); //this works for MKPinAnnotationView
self.enabled = NO;
self.backgroundColor = [UIColor clearColor];
self.cellInsetX = 15;
self.cellOffsetY = 10;
self.onCalloutAccessoryTapped = block;
[self setTitleWithAnnotation:annotation];
[self setCalloutCellsWithAnnotation:annotation];
}
return self;
}
- (id)initWithAnnotation:(id<MultiRowAnnotationProtocol>)annotation reuseIdentifier:(NSString *)reuseIdentifier {
self = [self initWithAnnotation:annotation reuseIdentifier:reuseIdentifier onCalloutAccessoryTapped:nil];
return self;
}
答案 0 :(得分:1)
点击注释时,调用此方法并传递坐标。
-(void)didSelectAnnotationAtCoordinate:(CLLocationCoordinate2D)coordinate
{
MKMapRect mapRect = [self.mapView visibleMapRect];
MKMapPoint point = MKMapPointForCoordinate(coordinate);
mapRect.origin.x = point.x - mapRect.size.width * 0.3;//change value
mapRect.origin.y = point.y - mapRect.size.height * 0.70;//change value
[self.mapView setVisibleMapRect:mapRect animated:YES];
}