Domanda

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!

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top