觸摸我如何能夠檢測MKOverlay或MKPolyline視圖觸摸事件?我試過this並在MKPolylineView上添加了tapgesture,但沒有成功。檢測上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方法沒有被激發。我希望獲得的所有內容都是當用戶點擊該多段線時顯示一個顯示多段線細節的彈出視圖。