1

我有一个 UIViewController,在上面我放了一个 UIImageView,然后是一个 UIScrollView。

我可以很好地处理 UIScrollView 上的触摸,但是我想处理 UIViewController 上的某些触摸。

我只需要触摸保持 5 秒的 UIScrollView(这部分工作正常)。任何小于我想要传递给 UIViewController 的东西。

在 UISCrollView 我称之为:

- (void) touchesBegan: (NSSet *) touches withEvent: (UIEvent *) event
{
// some custom code to process a specific touch.

// all other touches
    [super touchesBegan: touches withEvent: event];
}

有没有办法将触摸从 UIScrollView 传递到底部 UIViewController,或者我是否必须将对 UIViewController 的引用传递到 UIScrollView?

4

2 回答 2

1

解决了!

需要补充:

[self.nextResponder touchesEnded: touches withEvent:event]; 

到最顶层的控制器。

感谢我自己!

于 2010-08-14T02:42:33.203 回答
0

Apple 文档中的 touchesBegan 描述告诉我们:

要将消息转发给下一个响应者,请将消息发送给 super(超类实现);不要将消息直接发送给下一个响应者。例如,

[super touchesBegan:touches withEvent:event];

如果您在不调用 super 的情况下覆盖此方法(一种常见的使用模式),那么您还必须覆盖用于处理触摸事件的其他方法,如果只是作为存根(空)实现。

于 2012-08-24T05:21:49.487 回答