Ios UILongPressGestureRecognitor无法在自定义MKMapViewAnnotation上工作

Ios UILongPressGestureRecognitor无法在自定义MKMapViewAnnotation上工作,ios,objective-c,uigesturerecognizer,gesture,Ios,Objective C,Uigesturerecognizer,Gesture,我有一个自定义pin。UILongPressGestureRecognitor在该pin上不起作用,因为我实现了以下功能,有什么想法吗 - (void)handleLongPress:(UILongPressGestureRecognizer *)sender { if (sender.state == UIGestureRecognizerStateEnded) { NSLog(@"UIGestureRecognizerStateEnde

我有一个自定义pin。UILongPressGestureRecognitor在该pin上不起作用,因为我实现了以下功能,有什么想法吗

    - (void)handleLongPress:(UILongPressGestureRecognizer *)sender {
        if (sender.state == UIGestureRecognizerStateEnded) {
           NSLog(@"UIGestureRecognizerStateEnded");
          }
         else if (sender.state == UIGestureRecognizerStateBegan){
            NSLog(@"UIGestureRecognizerStateBegan.");
          }
    }


    -(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation{
    if([annotation isKindOfClass:[NewBBAnnotation class]]){
        NewBBAnnotation *cu=(NewBBAnnotation*)annotation;
        DealerPinView *cur= (DealerPinView *)[mapView dequeueReusableAnnotationViewWithIdentifier:cu.custCode];
        if(cur==nil)
            cur=[[DealerPinView alloc] initWithAnnotationAndButton:annotation reuseIdentifier:cu.custCode];
        else
            cur.annotation=annotation;
        [cur drawPinAnnotation:@"market" pinName:@"market" hasRedFlag:NO hasTimerFlag:NO longTouchPressed:NO isTransparent:NO isRemoteVisit:NO];

    UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
        [cur setUserInteractionEnabled:YES];
        longPress.minimumPressDuration = 2.0;
        longPress.delegate = self;
        [cur addGestureRecognizer:longPress];
            return cur;
    }
    else if ([annotation isKindOfClass:[MKUserLocation class]])
        return nil;
    return nil;
}
-(无效)手动长按:(UILongPress手势识别器*)发送方{
if(sender.state==UIGestureRecognitizerStateEnded){
NSLog(@“UIgestureRecognitzerStateEnded”);
}
else if(sender.state==UIgestureRecognitizerStateStart){
NSLog(@“UIgestureRecognitizerStateStart.”);
}
}
-(MKAnnotationView*)地图视图:(MKMapView*)地图视图注释:(id)注释{
if([annotation isKindOfClass:[NewBBAnnotation class]]){
NewBBAnnotation*cu=(NewBBAnnotation*)注释;
DEALERPIVIEW*cur=(DEALERPIVIEW*)[mapView dequeueReusableAnnotationViewWithIdentifier:cu.custCode];
如果(cur==nil)
cur=[[DealerPinView alloc]initWithAnnotationAndButton:annotation-reuseIdentifier:cu.custCode];
其他的
当前注释=注释;
[当前图纸注释:@“市场”品名:@“市场”有红色标志:无黑色标志:无长按:无透明:无ISREMOTE访问:无];
UILongPressGestureRecognitzer*longPress=[[UILongPressGestureRecognitzer alloc]initWithTarget:self action:@selector(handleLongPress:)];
[cur setUserInteractionEnabled:是];
longPress.minimumPressDuration=2.0;
longPress.delegate=self;
[cur addgesture识别器:longPress];
返回电流;
}
else if([annotation isKindOfClass:[MKUserLocation类]])
返回零;
返回零;
}

谢谢你的帮助

到底什么不起作用?长按手势不起作用。