如何检测 MKOverlay 或 MKPolyline 视图上的触摸事件?我已经尝试过这个并在 MKPolylineView 上添加了 Tapgesture 但没有成功。
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay
MKPolyline *mapPoly = (MKPolyline *)overlay;
MKPolylineView *_ucPolyView = [[MKPolylineView alloc] initWithPolyline:mapPoly];
_ucPolyView.strokeColor = [UIColor redColor];
[_ucPolyView setUserInteractionEnabled:YES];
UITapGestureRecognizer *polylineTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(polylineTapped:)];
polylineTap.numberOfTapsRequired = 1;
[_ucPolyView addGestureRecognizer:polylineTap];
}
-(void)polylineTapped:(UITapGestureRecognizer *)tapGesture
{
NSLog(@"Polyline is %@",tapGesture.view);
}
但是 polylineTapped 方法没有被解雇。我想要实现的只是在用户点击该折线时显示一个显示折线详细信息的弹出视图。