如何确定正在滚动UITableView的触摸次数 [英] How to determine number of touches that are scrolling UITableView

查看:54
本文介绍了如何确定正在滚动UITableView的触摸次数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView 称为&时,我正在尝试确定UITableView上的手指触摸次数.相应地执行一些任务.

I am trying to determine number of finger touches on UITableView when - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView is called & perform some task accordingly.

到目前为止,我尝试过的两种方法是:

Two approaches that I have tried so far are:

  1. 将UITableView子类化以覆盖 touchesBegan:withEvent:-这种方法的问题在于,仅当屏幕上有一些"轻击时才触发该方法,而当用户只是不滚动手指而快速滚动时,则不会触发这种方法.
  2. 使用 uipangesturerecognizer 检测触摸次数.--我以以下方式使用它:
  1. Subclassing UITableView to override touchesBegan:withEvent: - The problem with this approach is that this method is only fired when there is 'some' tap on the screen, not when the user just quickly scrolls without resting the finger.
  2. Using uipangesturerecognizer to detect number of touches. - I am using it in the following way:


UIPanGestureRecognizer *taps = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
taps.maximumNumberOfTouches=4;
taps.minimumNumberOfTouches=1;
[self.tableView addGestureRecognizer:taps];

然后

-(void)handleTap:(UITapGestureRecognizer *)sender{
    if (sender.state == UIGestureRecognizerStateBegan) {
        NSLog(@"BEGAN - %d",sender.numberOfTouches);
    }
}

虽然我可以通过这种方法获得触摸次数,但是问题是它覆盖了实际的滚动(没有发生正常的滚动).

Although I am able to get the number of touches with this approach, but the problem is that it is overriding actual scrolling (normal scrolling is not happening).

请提出我错了或应该做的其他事情.谢谢!

Please suggest where I am wrong or what else shall be done. Thanks!

推荐答案

UIGestureRecognizer的方法-(NSUInteger)numberOfTouches可以告诉您对其进行了多少次触摸.

The method -(NSUInteger)numberOfTouches of UIGestureRecognizer could tell you how many touches on it.

这篇关于如何确定正在滚动UITableView的触摸次数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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