2010-08-14 35 views
1

我有一個UIViewController,頂上我把UIImageView,然後UIScrollView。iPhone:接觸UIViewController

我可以在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?

回答

1

解決!

需要添加:

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

到最高控制器。

謝謝你自己!在蘋果文檔

0

的touchesBegan說明會告訴:

爲了將消息轉發到下一個響應者,將消息發送到超(超類實現);不要直接將消息發送給下一個響應者。例如,

[super touchesBegan:touches withEvent:event]; 

如果你沒有覆蓋超調用這個方法(一種常見的使用模式),您還必須重寫處理觸摸事件,如果僅僅作爲存根(空)實現的其他方法。

相關問題