使用UIPanGestureRecognizer UINavigationController向后滑动不起作用

时间:2016-10-04 12:13:09

标签: ios objective-c uinavigationcontroller uipangesturerecognizer uiswipegesturerecognizer

cellForRowAtIndexPath创建cell时,我还将UIPanGestureRecognizer添加到cell,并根据要求实施所有处理。

Tableview包含在myViewController中的UINavigationController中。

使用UIPanGestureRecognizer UINavigationController向后滑动无效。

当用户开始从手机的最左侧滑动时,如果执行UINavigationController swipe to back而不是我的手机平移手势,我该怎么做呢。

-(void)move:(PanGestureRecognizer *)gesture {

    CGPoint location = [gesture locationInView:self];
    NSIndexPath *swipedIndexPath = [self indexPathForRowAtPoint:location];
    TableViewCell *swipedCell  = [self cellForRowAtIndexPath:swipedIndexPath];
    CGRect cellRect = swipedCell.frame;

    if(location.x < 75) {
       ?????
    }

.
.
.
//my pan gesture required functionality
}


-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    return YES;
}

1 个答案:

答案 0 :(得分:0)

使用requireGestureRecognizerToFail

在viewController中调用[yourPanGesture requireGestureRecognizerToFail:self.navigationController.interactivePopGestureRecognizer

[cell.gestureRecognizers enumerateObjectsUsingBlock:^(__kindof UIGestureRecognizer * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        if ([obj isKindOfClass:[UIPanGestureRecognizer class]]) {
            [obj requireGestureRecognizerToFail:interactivePopGestureRecognizer];
        }
    }];