仅 iPhone 4.0 和 4.1 中存在手势识别器错误

发布于 2024-10-27 23:06:32 字数 612 浏览 7 评论 0原文

以下代码适用于 4.2 和 4.2 版本4.3 但在 4.0 和 4.0 中4.1 该值显示为 NaN,但仅限于 UIGestureRecognizerStateEnded 情况。它显示了 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", touchPoint.x); // Always outputs nan
}

不确定这是否是苹果部分的错误或者我是否做错了什么。请指教

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", touchPoint.x); // Always outputs nan
}

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

や三分注定 2024-11-03 23:06:32

看看我自己的代码,我从未检查过开始/结束状态中的坐标。我只是将它们视为单独的事件,与屏幕上的位置无关。在 End 情况下,我假设 Changed 发送的最后一个坐标。在开始的情况下,我不能相信坐标,因为它们是在手势移动一点并且手势开始后确定的,所以我询问我的点击识别器初始坐标在哪里。

我怀疑这是最初的意图,即使用 Changed,但在 4.2 和 4.3 中,他们也开始填写 End 的最终坐标,只是为了保持一致。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文