使用 UIScreenEdgePanGestureRecognizer 快速平移时,translationInView 等于 0 [英] translationInView equal to 0 when fast panning using UIScreenEdgePanGestureRecognizer

查看:31
本文介绍了使用 UIScreenEdgePanGestureRecognizer 快速平移时,translationInView 等于 0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个测试项目来显示问题.

I created a test project showing the problem.

当我从左边缘或右边缘快速平移时,在状态 UIGestureRecognizerState.Began 期间,translationInView 等于 (0.0, 0.0).当您处于 landscape 并在设备的下半部分(在我的情况下为 iphone 6)或当您处于 portrait 并在大约屏幕的前三分之一部分(从底部开始).

When I do a fast pan from the left or right edge, during the state UIGestureRecognizerState.Began, the translationInView is equal to (0.0, 0.0). This happens when you are in landscape and do the gesture in the lower half of the device (iphone 6 in my case) or when you are in portraitand do the gesture in about the 1rst third part of the screen (from the bottom).

这……正常吗?我想它可能知道但找不到任何东西.

Is it... normal? I guess it's probably know but couldn't find anything.

推荐答案

我认为您的代码没有任何问题.translationInView(_:) 返回的值是相对于手势开始的第一个点的,这在 .Began 期间是有意义的,因为紧接在第一个点之后的是成立.

I don't think there's anything wrong with your code. The value returned by translationInView(_:) is relative to the first point where the gesture began, which makes sense during the .Began because that is immediately after that first point is established.

另外,只是想确保您了解您使用的是 UIScreenEdgePanGestureRecognizer 而不是其他一些 UIPanGestureRecognizer.UIScreenEdgePanGestureRecognizer 的正常行为是仅在屏幕边缘附近处于活动状态,这解释了您所描述的活动区域.既然你提到了,只是想确保没有混淆(如果不是这样,请告诉我).

Also, just want to make sure you understand that you are using UIScreenEdgePanGestureRecognizer and not some other UIPanGestureRecognizer. The normal behavior of UIScreenEdgePanGestureRecognizer is to only be active near the screen edges, which explains the active areas you are describing. Since you mention it, just want to make sure there's no confusion (please person me if that's not the case).

这篇关于使用 UIScreenEdgePanGestureRecognizer 快速平移时,translationInView 等于 0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆