不允许UIScrollView捕获子视图 [英] Disallow UIScrollView from catching subviews touches

查看:154
本文介绍了不允许UIScrollView捕获子视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UIScrollView 覆盖了自定义 UIView ,它绝对需要监听所有的触摸事件

I've got a UIScrollView covered with a custom UIView which desperatly needs to listen to all the touch events that happen inside of him.

首先,我得到的是 touchesBegan: touchesCancelled:事件。否 touchesMoved:,否 touchesEnded:。事实上,所有拖动手势都被上面的 UIScrollView 取消了。这是通过以下设置解决的:

At first, all I was getting was touchesBegan: and touchesCancelled: events. No touchesMoved:, no touchesEnded:. In fact, all the dragging gestures where being canceled by the above UIScrollView. This was solved by the following setting:

_scrollView.canCancelContentTouches = NO;

现在,行为会根据第一次触摸UIView的时间长度而改变。如果它很短,那么相对拖动被管理,因为它是 UIScrollView 的滚动。如果它很长,那么我会在我的UIView中获得 touchesMoved:事件。

Now, the behaviour changes depending on the "length in time" of the first touch on the UIView. If it's short, then the relative dragging is managed as it was a scroll for the UIScrollView. If it's long, then I'm getting the touchesMoved: events inside my UIView.

我想要的是总是在我的UIView中接收 touchesMoved:

What I want is to always receive touchesMoved: inside my UIView. How can I make it?

推荐答案

您是否已尝试修改 delaysContentTouches 属性 UIScrollView ?我有一个类似的问题,解决了。

Have you tried modifying the delaysContentTouches property of your UIScrollView? I had a similar issue, solved it.

这篇关于不允许UIScrollView捕获子视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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