Как я могу обнаружить события касания на MKOverlay или MKPolyline? Я попробовал this и добавил tapgesture на MKPolylineView, но не добился успеха.Обнаружение касаний на MKOverlay
- (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 не запускается. Все, что я хочу видеть, это отобразить всплывающее представление, показывающее детали полилинии всякий раз, когда пользователь нажимает на эту полилинию.