1

I'm using a UIGestureRecognizer from here: Tap pressure strength detection using accelerometer

I'm adding the recognizer to the entire view like this:

CPBPressureTouchGestureRecognizer *recognizer = [[CPBPressureTouchGestureRecognizer alloc] initWithTarget:self action:@selector(tapped)];
[self.view addGestureRecognizer:recognizer];

-(void)tapped {
    NSLog(@"number of touches: %d", [recognizer numberOfTouches]);
}

It works fine as far as showing the correct number of touches in tapped() if I tap my finger slow on the screen. If I tap very quickly, it periodically registers 0 number of touches even though it calls the tapped() method for every touch.

Any idea why it would not be able to consistently receive the touch data?

Thanks!

Community
  • 1
  • 1
codeman
  • 8,868
  • 13
  • 50
  • 79
  • Some code from the implementation of your subclass would be helpful. – Mark Adams Dec 27 '11 at 20:43
  • It's on the page I linked to. – codeman Dec 27 '11 at 20:44
  • From a cursory glance, it appears to be related to the pressure detected via the accelerometer falling below or above the acceptable boundaries. If you log the gesture recognizers state on every tap as well, I think you'll find that the state is `UIGestureRecognizerStateFailed` when the touches are 0. – Mark Adams Dec 27 '11 at 20:47
  • Just tried ouputting the state. The state is consistent and never is failed. Any other ideas? – codeman Dec 27 '11 at 21:02
  • The only other thing that stands out is the `kUpdateFrequency` that determines how often the accelerometer reports back. Try lowering the frequency to see if it yields any changes. – Mark Adams Dec 27 '11 at 21:24
  • That did seem to help a bit, although I can still cause it to register no touches. It's a lot better though. Thank you. I do notice that the registering of this gesture recognizer is a lot slower than if you were just intercepting touchesBegan yourself. Seems to be quite a bit of delay by the time it reaches the tapped() function. – codeman Dec 27 '11 at 21:34

0 Answers0