【发布时间】:2012-01-05 15:09:03
【问题描述】:
我在应用中有自定义注释引脚:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
return [kml viewForAnnotation:annotation type:state];
}
我返回自定义视图并为 Placemark 的 annotationView 制作 setImage,例如:
- (MKAnnotationView *)viewForAnnotation:(id <MKAnnotation>)point type:(int)state
{
// Find the KMLPlacemark object that owns this point and get
// the view from it.
for (KMLPlacemark *placemark in _placemarks) {
if ([placemark point] == point)
{
UIButton *disclosureButton = [UIButton buttonWithType: UIButtonTypeDetailDisclosure];
[[placemark annotationView] setCanShowCallout: YES];
[[placemark annotationView] setRightCalloutAccessoryView:disclosureButton];
if (state == 0)
{
[[placemark annotationView] setImage:[UIImage imageNamed:@"ic_pin_tour.png"]];
}
else
{
[[placemark annotationView] setImage:[UIImage imageNamed:@"ic_pin_point.png"]];
}
return [placemark annotationView];
}
}
return nil;
}
但是如果我长按我的注释图钉,它的外观会更改为默认视图 (RedPin)。 我不明白长按时调用了什么方法。我尝试使用 UITapGestureRecognizer,但没有发现。如果我只是点击注释针,一切正常,我的自定义注释针视图不会消失。 您可以在此屏幕截图中看到我的意思:
那么,为什么长按时注释针的外观会发生变化?
【问题讨论】:
标签: iphone ios google-maps mkmapview mkpinannotationview