iPhone SDK-将触摸从UIViewController转发到子视图 [英] iPhone SDK - Forwarding touches from a UIViewController to a subview
问题描述
我有一个 UIViewController
,其上有一个名为 customSubView1
的 UIView
子类.然后在customSubView1上,我有另一个 UIView
的子类,称为 customSubView2
.
I have a UIViewController
with a subclass of UIView
on it called customSubView1
. Then on customSubView1 I have another subclass of UIView
called customSubView2
.
将 touchesBegan/touchesMoved/etc
放入 UIViewController
类中时,我可以捕获所有子视图上所有触摸的事件.但是我希望能够在我的自定义类中对其进行处理.
I can capture all the events for touches on all the subviews when I put touchesBegan/touchesMoved/etc
in the UIViewController
class. But I want to be able to process them in my custom classes.
我一直在阅读 UIViewController
类需要将触摸事件转发"到子视图,但是我无法找到任何示例代码来执行此操作.有人知道吗?
I keep reading that the UIViewController
class needs to 'forward' the touch events to the subviews, but I haven't been able to find any example code to do this. Does anyone have any idea?
非常感谢,布雷特(Brett)
Many thanks, Brett
推荐答案
尝试为您设置 UIView
对象 userInteractionEnabled
属性:
Try to set for you UIView
object userInteractionEnabled
property:
myUIView.userInteractionEnabled = YES;
这篇关于iPhone SDK-将触摸从UIViewController转发到子视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!