开发者

Gesture Recognizer bug only in iPhone 4.0 and 4.1

The following code works in 4.2 & 4.3 but in 4.0 & 4.1 the value comes up as NaN, but only in the UIGestureRecognizerStateEnded case. It shows the correct value in UIGestureRecognizerStateChanged

- (void)panGesture:(UIPanGestureRecognizer*)gestureRecognizer
{
  CGPoint touchPoint = [gestureRecognizer locationInView:self];
  switch ( [gestureRecognizer state] ) {
    case UIGestureRecognizerStateChanged:
      NSLog(@"panChanged - touchPoint = %f", touchPoint.x); // Always works
    case UIGestureRecognizerStateEnded:
      NSLog(@"panEnded - touchPoint = %f", touch开发者_如何学GoPoint.x); // Always outputs nan
}

not sure if this is a bug on apples part or if I'm doing something wrong. Please advise


Looking at my own code, I never checked the coordinates in the Begin/End states. I just treated them as separate events, no related to the position on the screen. In the End case I assume the last coordinates sent by Changed. And in the Begin case I cannot trust the coordinates because they were determined after the gesture moved a little and the gesture began, so I ask my tap recognizer where the initial coordinates were.

I suspect that this was the original intent, that Changed be used, but in 4.2 and 4.3 they started filling in the final coordinates for End as well, just to be consistent.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜