UIScrollViewer.userinteractionenabled=true 时不会触发触摸事件
Posted
技术标签:
【中文标题】UIScrollViewer.userinteractionenabled=true 时不会触发触摸事件【英文标题】:Touch events does not fired when UIScrollViewer.userinteractionenabled=true 【发布时间】:2012-03-05 06:38:01 【问题描述】:在我的应用中有 UIScrollViewer(uiimageview inside this),当 userinteractionenabled=true 时,应用中不会触发触摸事件。如何使用 userinteractionenabled=true 启用触摸事件。
我尝试过使用 UITapGestureRecognizer,效果很好。但通常我将事件附加到 touchesBegan 事件内的按钮,因为现在我已经应用了 UITapGestureRecognizer,然后在此我只做需要在 touchesBegan 事件中完成的事情,但现在点击按钮的事件不会触发。我需要在我的应用中获取这些事件。
请帮帮我!
【问题讨论】:
【参考方案1】:由于您的图像视图位于滚动视图之上,因此 touchesBegan 不会产生预期的效果。滚动视图吞噬了所有的触摸。它与启用用户交互无关。
要使滚动视图的子视图能够触摸,您必须自己传递触摸。在这个答案中有一个Look。
【讨论】:
如果我应用 userinteractionenabled=false,touchesBegan 事件具有所有效果,但当 userinteractionenabled=true 时没有响应.. @MandeepKaur。我回答了你的问题。启用滚动视图后,它会吞噬所有触摸。【参考方案2】:莫伯你需要tabContent.multipleTouchEnabled = YES
?
【讨论】:
以上是关于UIScrollViewer.userinteractionenabled=true 时不会触发触摸事件的主要内容,如果未能解决你的问题,请参考以下文章