我有主wiev。我放置了一个 UIScrollView 对象作为主视图的子视图。我有一个来自 UIView 的扩展类,它管理触摸事件。此类模拟一种透明黑板,用户可以在其中绘制路径。我从 UIVIew 扩展类中创建了一个对象,并将其添加为 UIScrollView 的子视图。
我通过使用 Inspector 和 .xib 文件来执行此过程。
然后,没有触摸事件到达 UIScrollView 对象。无论我是否在检查器中取消选中我的 UIView 扩展类的“启用用户交互”复选框。我也尝试过:
[[self nextResponder] touchesBegan:touches withevent:event];
或者
[[self.superview nextResponder] touchesBegan:touches withevent:event];
或者
[super touchesBegan:touches withEvent:event];
或者
[super touchesBegan:touches withEvent:event];
在我的扩展 UIView 类的 touchEvents 方法中。我还没有成功地将触摸事件传递给 UIScrollView。
另一方面,如果我以编程方式添加 scrollView 和我的扩展 UIView 类,保持相同的层次结构,UIScrollView 获取触摸事件,但不是它的子视图(我的 UIView 扩展类)。
我不希望 UIScrollView 和我的 UIView 扩展类同时管理触摸事件。我只想在 UIScrollView 和我的 UIView 扩展类之间切换以收听触摸事件,例如使用按钮。
在这种情况下,我正在解释,是否有可能选择哪个 UIScrollView 或我的 UIView 扩展类应该监听触摸事件?