我有一个UIViewController,其中包含名为customSubView1的UIView子类。 然后在customSubView1上,我有另一个名为customSubView2的UIView子类。
当我将touchesBegan / touchesMoved等放入UIViewController类中时,可以捕获所有子视图上的触摸事件。 但是我想能够在我的自定义类中处理它们。
我一直在阅读UIViewController类需要“转发”触摸事件到子视图,但我还没有找到任何示例代码来实现这一点。 有人有任何想法吗?
非常感谢, Brett
当我将touchesBegan / touchesMoved等放入UIViewController类中时,可以捕获所有子视图上的触摸事件。 但是我想能够在我的自定义类中处理它们。
我一直在阅读UIViewController类需要“转发”触摸事件到子视图,但我还没有找到任何示例代码来实现这一点。 有人有任何想法吗?
非常感谢, Brett
userInteractionEnabled = YES
(对于直接的 UIView 子类应该是默认值)?它们可能在 scrollView 中吗?你是否尝试过最基本的方法,以排除其他错误的原因?CustomViewClass *myCustomTestView = [[CustomViewClass alloc] initWithFrame:CGRectMake(100,100,100,100)]; myCustomView.userInteractionEnabled = YES; myCustomView.backgroundColor = [UIColor redColor]; [self.view addSubview:myCustomView];
应该可以工作。 - fzwo