我在应用程序中有自定义的注释图钉:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
return [kml viewForAnnotation:annotation type:state];
}
我在这里返回自定义视图并为Placemark的注释视图设置setImage,例如:
我在这里返回自定义视图并为Placemark的注释视图设置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进行操作,但没有找到答案。如果我只是点击注释图钉,一切都正常,我的自定义注释图钉视图不会消失。您可以在此屏幕截图中看到我的意思:那么,为什么注释图钉在长按时会更改外观?