touchesBegan在UIView没有被调用 [英] touchesBegan in UIView not being called

查看:386
本文介绍了touchesBegan在UIView没有被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题必须回答很多次,但现在真的让我头痛。

I know that this question must be answered a lot of times already, but it is really giving me a headache right now.

touchesBegan:没有在我的UIView中调用。在我将它添加到我的应用程序之前,我首先做了一个试验项目。在试验项目中,一切工作完美。我做的是子类一个UIView,其中 touchesBegan:正在实现,并添加这个UIView作为另一个视图的子视图。第二个视图有一个按钮,显示一旦点击的子类UIView。

The touchesBegan: is not being called in my UIView. Before I added it in my app, I made a trial project first. In the trial project, everything worked perfectly. What I did was subclass a UIView where the touchesBegan: is being implemented, and add this UIView as a subview of another view. This second view has a button which shows the subclassed UIView once clicked. Again, everything works exactly how I want it to.

现在,当我在现有的应用程序中执行相同的操作时, touchesBegan:方法(以及 touchesMoved:)从未被调用。任何人都可以向我解释为什么?我只是不明白为什么它从未被调用。

Now, when I did the same thing in my existing app, the touchesBegan: method (as well as the touchesMoved:) is never called. Can anyone explain to me why? I just don't really understand why it was never called.

推荐答案

我刚才找到了答案。我忘了提到的视图是在另一个UIView,其中userInteraction被禁用(默认情况下禁用)。所以当我启用了这个视图的userInteraction,触摸现在被识别。

I just found the answer to this. I forgot to mention that the view is inside another UIView, which the userInteraction is disabled (It is disabled by default). So when I enabled the userInteraction of this view, the touches are now being recognized.

这篇关于touchesBegan在UIView没有被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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