iPhone:触及UIViewController

时间:2010-08-14 02:24:18

标签: ios objective-c touches

我有一个UIViewController,在顶部我放了一个UIImageView,然后是一个UIScrollView。

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

我只需触摸UIScrollView,持续5秒钟(这部分工作正常)。比我想要传递给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?

2 个答案:

答案 0 :(得分:1)

解决!

需要添加:

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

到最顶层的控制器。

谢谢你!

答案 1 :(得分:0)

Apple文档中的

touchesBegan描述告诉:

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

[super touchesBegan:touches withEvent:event];

如果在不调用super(常用模式)的情况下覆盖此方法,则还必须覆盖处理触摸事件的其他方法,如果仅作为存根(空)实现。