iOS:为什么touchesBegan在UIView的某些特定区域会有一些延迟 [英] iOS: Why touchesBegan has some delay in some specific area in UIView

查看:361
本文介绍了iOS:为什么touchesBegan在UIView的某些特定区域会有一些延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作自定义键盘,但我的情况确实很奇怪。

I'm making a custom keyboard and I'm in a really weird situation.

我注意到,当我捕捉到该事件时,touchsBegan位于左后方(约20像素)的UIView(inputView),我在这里会有一些延迟。
我在touchesBegan中执行的任何操作都将比其他区域执行得慢。

I've noticed that when I catch the event touchesBegan at the rear left (about 20 pixels) of the UIView (inputView), I'll have some delay in here. Any action I do in touchesBegan will be perform slower than other area.

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?)
{
self.keypop.hidden = false
}

override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
{
self.keypop.hidden = true
}

此问题影响我的应用程序的性能。
在此示例中,当我触摸左后方时,不会看到按键弹出消息,因为 self.keypop.hidden 被延迟显示。

And this trouble affects my app's performance. In this example, I will not see the keypop appears when I touched on the rear left because self.keypop.hidden was delayed in showing up.

我不知道为什么,或者这是iOS 9的错误?
这个问题困扰了我一个星期。

I don't know why, or is this an error from iOS 9? I've been stuck on this trouble for a week.

推荐答案

在我的情况下,我在CollectionView,当我点击
时,它会延迟触摸。通过简单地添加以下代码,它与我合作

In my situation I was using touchBegan in a CollectionView and it was delaying touches when I tap Its worked with me by simply added this code

在Swift中,

self.collectionView.delaysContentTouches = false
/*delaysContentTouches applies to all UIScrollView instances.*/

这篇关于iOS:为什么touchesBegan在UIView的某些特定区域会有一些延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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