Objective c UILongPress手势识别器和UITableview

Objective c UILongPress手势识别器和UITableview,objective-c,uitableview,scroll,uigesturerecognizer,Objective C,Uitableview,Scroll,Uigesturerecognizer,我有一个ui表格视图,其中每一行都添加了一个ui图像,带有ui长按手势识别器。现在我有一个问题,当触摸imageView时,会执行手势识别器的代码。但当我向上/向下移动手指时,表格视图不会滚动 UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] i

我有一个
ui表格视图
,其中每一行都添加了一个
ui图像
,带有
ui长按手势识别器
。现在我有一个问题,当触摸imageView时,会执行手势识别器的代码。但当我向上/向下移动手指时,表格视图不会滚动

     UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]
                                                                   initWithTarget:self
                                                                   action:@selector(handleLongPress:)];
    longPress.minimumPressDuration = 1.0;
    [cell addGestureRecognizer:longPress];

  -  (void)handleLongPress:(UILongPressGestureRecognizer*)sender {
        CGPoint location = [sender locationInView:yourtableviewobj];
        //Get the corresponding index path within the table view
        NSIndexPath *indexPath = [self.tablechat indexPathForRowAtPoint:location];
        if (sender.state == UIGestureRecognizerStateEnded) {
      }
        else if (sender.state == UIGestureRecognizerStateBegan){
       }
    }
这很清楚,因为触摸仍然在手势识别器中

     UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]
                                                                   initWithTarget:self
                                                                   action:@selector(handleLongPress:)];
    longPress.minimumPressDuration = 1.0;
    [cell addGestureRecognizer:longPress];

  -  (void)handleLongPress:(UILongPressGestureRecognizer*)sender {
        CGPoint location = [sender locationInView:yourtableviewobj];
        //Get the corresponding index path within the table view
        NSIndexPath *indexPath = [self.tablechat indexPathForRowAtPoint:location];
        if (sender.state == UIGestureRecognizerStateEnded) {
      }
        else if (sender.state == UIGestureRecognizerStateBegan){
       }
    }

有没有办法让我的手势识别器中的tableView滚动?也就是说,当我在手势识别器中,手指向上移动时,我称之为tableView滚动方法?

我认为它可能对您有用

     UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]
                                                                   initWithTarget:self
                                                                   action:@selector(handleLongPress:)];
    longPress.minimumPressDuration = 1.0;
    [cell addGestureRecognizer:longPress];

  -  (void)handleLongPress:(UILongPressGestureRecognizer*)sender {
        CGPoint location = [sender locationInView:yourtableviewobj];
        //Get the corresponding index path within the table view
        NSIndexPath *indexPath = [self.tablechat indexPathForRowAtPoint:location];
        if (sender.state == UIGestureRecognizerStateEnded) {
      }
        else if (sender.state == UIGestureRecognizerStateBegan){
       }
    }

我想这可能对你有用

     UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]
                                                                   initWithTarget:self
                                                                   action:@selector(handleLongPress:)];
    longPress.minimumPressDuration = 1.0;
    [cell addGestureRecognizer:longPress];

  -  (void)handleLongPress:(UILongPressGestureRecognizer*)sender {
        CGPoint location = [sender locationInView:yourtableviewobj];
        //Get the corresponding index path within the table view
        NSIndexPath *indexPath = [self.tablechat indexPathForRowAtPoint:location];
        if (sender.state == UIGestureRecognizerStateEnded) {
      }
        else if (sender.state == UIGestureRecognizerStateBegan){
       }
    }

yourLongPressGestureRecognizer.allowableMovement=0
并且应该实现如下委托方法:
-(BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer应该与gestureRecognizer:(UIGestureRecognizer*)otherGestureRecognizer{返回YES;}同时识别
yourLongPressGestureRecognizer.allowableMovement=0
并且您应该实现如下委托方法:
-(BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer应该与gestureRecognizer:(UIGestureRecognizer*)同时识别其他gestureRecognizer{返回YES;}
对于测试另一个tableview问题有帮助:)对于测试另一个tableview问题有帮助:)