2010-08-31 58 views

回答

1

講究,如果任何視圖添加到窗口捕獲事件,不轉發它,window對象永遠不會收到它。 UIScrollView通常會這樣做。在這種情況下,你還需要繼承阻塞視圖轉發這樣的事件,例如:

在一個UIScrollView子類

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { 
    if (!self.dragging) { 
     [self.nextResponder touchesEnded: touches withEvent:event]; 
    }  
    [super touchesEnded: touches withEvent: event]; 
} 
+0

UIScrollView的子類是指,請給交代.....我可以直接處理在appdelegate.m文件觸摸事件的UIWindow – 2010-09-01 03:53:56

+0

子類的UIScrollView意味着創建一個從繼承的UIScrollView像 @interface myScrollView類:UIScrollView的{} @ 結束 – VdesmedT 2010-09-01 08:04:53

3

查看Apple的UIResponder類文檔。 UIWindow從UIResponder類下降,因此可以選擇處理包含UIViews的所有UI事件,包括觸摸事件。

+0

任何教程嗎? – 2010-08-31 09:05:27

1

子類從一個UIWindow

你的窗口

然後實現: 的touchesBegan,touchesMoved,touchesEnd功能