`touchesBegan:withEvent:`在屏幕左边延迟 [英] `touchesBegan:withEvent:` is delayed at left edge of screen

查看:146
本文介绍了`touchesBegan:withEvent:`在屏幕左边延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一个问题,在 UIView 或<$上首次调用 touchesBegan:withEvent:当您触摸屏幕的左边缘时,c $ c> UIViewController 会延迟。这似乎是iOS 10的一个新问题,只发生在具有3D Touch(iPhone 6s和更新版本)的设备上。事实上,如果您在General-> Accessibility中禁用3D Touch,则问题就会消失。

I'm experiencing an issue where the first call to touchesBegan:withEvent: on a UIView or UIViewController is delayed when you touch on the left edge of the screen. This seems to be a new issue with iOS 10, and only happens on devices with 3D Touch (iPhone 6s and newer). In fact, if you disable 3D Touch in General->Accessibility, the issue goes away.

但是,使用<$ c时似乎不会出现此问题$ C> UIGestureRecognizers 。我目前的解决方法是创建一个 UIGestureRecognizer 子类,它覆盖 touches * 方法并将它们转发到我的旧实现。

However, the issue doesn't seem to happen when you use UIGestureRecognizers. My workaround at the moment is to create a UIGestureRecognizer subclass that overrides the touches* methods and forwards them to my old implementation.

这只是一个错误还是有办法摆脱延迟?

Is this just a bug or is there a way to get rid of the delay?

推荐答案

尝试将此添加到viewdidappear方法。这可能会解决问题。它也发生在我身上,但我从堆栈溢出中得到了这个代码来解决我的问题。希望它也能帮助你

try adding this to the viewdidappear method. this might fix the issue. it happened with me as well but i got this code from stack overflow that fixed my issue. hope it helps you too

let window = view.window!
let gr0 = window.gestureRecognizers![0] as UIGestureRecognizer
let gr1 = window.gestureRecognizers![1] as UIGestureRecognizer
gr0.delaysTouchesBegan = false
gr1.delaysTouchesBegan = false

这篇关于`touchesBegan:withEvent:`在屏幕左边延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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