UITableView滑动手势需要近乎完美的准确性 [英] UITableView swipe gesture requires near perfect accuracy

查看:556
本文介绍了UITableView滑动手势需要近乎完美的准确性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个自定义swipe事件的UITableView使用自定义UITableViewCell子类。我在我的标题中包含 UIGestureRecognizerDelegate ,并且在 viewDidLoad中有这个:

I'm working on a custom swipe event for a UITableView that uses custom UITableViewCell subclass. I included the UIGestureRecognizerDelegate in my header, and have this in viewDidLoad:

UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipe:)];
swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
swipeLeft.numberOfTouchesRequired = 1;
[self.tableView addGestureRecognizer:swipeLeft];

我的swipeLeft方法如下:

My swipeLeft method looks like so:

-(void)didSwipe:(UISwipeGestureRecognizer *)recognizer {

    if (recognizer.state == UIGestureRecognizerStateEnded)
    {
        CGPoint swipeLocation = [recognizer locationInView:self.tableView];
        NSIndexPath *swipedIndexPath = [self.tableView indexPathForRowAtPoint:swipeLocation];
        NSDictionary *clip = [self.clips objectAtIndex:swipedIndexPath.row];
        NSLog(@"Swiped!");


    }
}

>排序的工作,但滑动必须是令人难以置信的精确。像几乎不可能精确。

It's sort of working, but the swipe has to be incredibly precise. Like nearly impossibly precise.

我几乎得到它的工作通过使用UIPanGestureRecognizer,但不幸的是它没有玩全局侧抽屉组件使用全局泛手势识别器(ECSlidingViewController为那些感兴趣的)。

I almost got it working by using a UIPanGestureRecognizer instead, but unfortunately it didn't play nice with the global side drawer component that uses a global pan gesture recognizer (ECSlidingViewController for those interested).

有什么办法吗?

推荐答案

如同指出的那样,任何帮助都会受到赞赏,因为我一直在寻找解决方案。在Twitter上通过 Kolin Krewinkel 发布,实现这两个代理方法的诀窍:

As pointed out by Kolin Krewinkel on Twitter, implementing these 2 delegate methods did the trick:

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

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

这篇关于UITableView滑动手势需要近乎完美的准确性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆