Ios 如果我';我正在使UITableViewCell可滑动(用于快速删除)如何使其成为';它还可以打开吗?

Ios 如果我';我正在使UITableViewCell可滑动(用于快速删除)如何使其成为';它还可以打开吗?,ios,objective-c,uitableview,uigesturerecognizer,Ios,Objective C,Uitableview,Uigesturerecognizer,我已经成功地使我的UITableViewCell可以左右滑动,以将单元格标记为已读,或将其删除(有点像Reder应用程序的操作方式),但现在它不允许我简单地点击它。我如何允许它也被点击 我使用了这个概念的结构,所以这里有更多的信息 我按如下方式实施了滑动: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { _firstTouchPoint = [[touches anyObject] locationIn

我已经成功地使我的UITableViewCell可以左右滑动,以将单元格标记为已读,或将其删除(有点像Reder应用程序的操作方式),但现在它不允许我简单地点击它。我如何允许它也被点击

我使用了这个概念的结构,所以这里有更多的信息

我按如下方式实施了滑动:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    _firstTouchPoint = [[touches anyObject] locationInView:self];
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    CGPoint touchPoint = [[touches anyObject] locationInView:self];

    // Holds the value of how far away from the first touch the finger has moved
    CGFloat xPos;

    // If the first touch point is left of the current point, it means the user is moving their finger right and the cell must move right
    if (_firstTouchPoint.x < touchPoint.x) {
        xPos = touchPoint.x - _firstTouchPoint.x;

        if (xPos <= 0) {
            xPos = 0;
        }
    }
    else {
        xPos = -(_firstTouchPoint.x - touchPoint.x);

        if (xPos >= 0) {
            xPos = 0;
        }
    }

    // Change our cellFront's origin to the xPos we defined
    CGRect frame = self.cellFront.frame;
    frame.origin = CGPointMake(xPos, 0);
    self.cellFront.frame = frame;

}

- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
    [self springBack];
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    [self springBack];
}

- (void)springBack {
    CGFloat cellXPositionBeforeSpringBack = self.cellFront.frame.origin.x;

    CGRect frame = self.cellFront.frame;
    frame.origin = CGPointMake(0, 0);

    [UIView animateWithDuration:0.1 delay:0.0 options:UIViewAnimationOptionCurveEaseOut animations:^{
        self.cellFront.frame = frame;
    } completion:^(BOOL finished) {

    }];

    if (cellXPositionBeforeSpringBack >= 80 || cellXPositionBeforeSpringBack <= -80) {
        NSLog(@"YA");
    }
}
-(void)touchesbeated:(NSSet*)toucheevent:(UIEvent*)event{
_firstTouchPoint=[[触摸任何对象]位置查看:self];
}
-(无效)触摸移动:(NSSet*)触摸事件:(UIEvent*)事件{
CGPoint touchPoint=[[touchs anyObject]locationInView:self];
//保存手指移动到距离第一次触摸多远的值
CGXPO;
//如果第一个接触点位于当前点的左侧,则表示用户正在向右移动手指,并且单元格必须向右移动
如果(_firstTouchPoint.x如果(cellXPositionBeforeSpringBack>=80 | | cellXPositionBeforeSpringBack最容易解决的问题,实际上是建立自己左右滑动的姿势。
构建后,只需将此手势添加到视图中,并添加轻触手势

如果您通过实现“ShouldRecognitizeSimultaneousyWithGestureRecognitzer”方法让这两种手势(点击手势和滑动手势)同时生效,iOS将非常轻松地为您处理

以下是如何构建自定义手势识别器:


只需使用UIPangestureRecognitor即可

触碰开始的方法太古老了。
通过平移手势,您将不会丢失手机上的触摸事件。

如果您只使用
UISweepGestureRecognitizer
会更容易,如果您使用表格视图
delete
功能会更好。这两种功能都不提供必要的功能。