UISystemGateGestureRecognizer和屏幕底部附近的延迟点击 [英] UISystemGateGestureRecognizer and delayed taps near bottom of screen
问题描述
在iOS应用的顶级 UIView
上安装了哪些标准 UISystemGestureGateGestureRecognizers
?
What are the standard UISystemGestureGateGestureRecognizers
installed on the top level UIView
of an iOS app for?
我的应用程序包含两个视图 - 一个填充屏幕的上半部分,另一个是自定义键盘并填充下半部分。我发现空格键上的水龙头并不总是有效,经过一些调查后发现底部20像素左右的点击事件的时间与视图的其余部分不同。对于大多数观点来说,touchesBegan / Ended之间的时间间隔约为100ms,而空格键则为1-2ms。 (我的应用程序是一个模拟器,它太快,无法检测按键)。
My app consists of two views - one fills the top half of the screen, the other is a custom keyboard and fills the bottom half. I found that taps on the space bar didn't always work and after some investigation found that the timing of tap events in the bottom 20 pixels or so was different to the rest of the view. For most of the view the period between touchesBegan/Ended was about 100ms, where as for the space bar it was 1-2ms. (My app is an emulator and this is too fast for it to detect the key press).
经过多次挖掘后,我找到了主要的 UIView应用程序的
(即:我的主视图的超级视图)安装了2 UISystemGestureGateGestureRecognizer
。通过在 ViewDidAppear
中删除它们,屏幕底部不再受影响。 (据推测,这些会将触摸按键事件取消到我的键盘,因此时间更快)。
After some more digging I found the main UIView
of the application (ie: my main view's superview) has 2 UISystemGestureGateGestureRecognizer
's installed. By removing them in ViewDidAppear
the bottom of the screen is no longer affected. (Presumably these are cancelling the touch press events to my keyboard hence the faster timing).
这些系统识别器至少出现在iOS 5到7以及iPad和iPad上苹果手机。我认为它们可能与从顶部/底部滑动相关,但是这个功能仍然适用于它们被移除。
These system recognizers are present on at least iOS 5 through 7 and on both iPad and iPhone. I thought they may be related to swipe from top/bottom but this functionality still works with them removed.
所以我有一个修复,但我想了解更多关于这里发生了什么 - 特别是我可能会通过删除这些来打破。
So I have a fix, but I'd like to understand more about what's going on here - in particular what I might be breaking by removing these.
推荐答案
这种延迟的接触也困扰着我。
正如之前所说的那样,
这是一个简单的修复:
This delayed touches bothered me too. Just as an addition to what's said before, here's a simple fix:
override func viewDidAppear(_ animated: Bool) {
let window = view.window!
let gr0 = window.gestureRecognizers![0] as UIGestureRecognizer
let gr1 = window.gestureRecognizers![1] as UIGestureRecognizer
gr0.delaysTouchesBegan = false
gr1.delaysTouchesBegan = false
}
无需删除这些手势识别器。
只需将其添加到主视图控制器。
no need to remove those gesture recognizers. just add this to the main view controller.
这篇关于UISystemGateGestureRecognizer和屏幕底部附近的延迟点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!