How to determine number of touches that are scrolling UITableView

纵然是瞬间 提交于 2019-12-12 03:23:34

问题


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. 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];

And then

-(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!


回答1:


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



来源:https://stackoverflow.com/questions/8500549/how-to-determine-number-of-touches-that-are-scrolling-uitableview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!