2014-02-23 19 views
0

我重寫hitTest:withEvent迴歸自我(最底層的視圖)迴應 -Progamatically啓動則hitTest:WithEvent後手勢識別被取消,返回不同的UIView對事件

當返回self - 我認爲會響應觸摸事件又會啓動手勢識別器。

如果手勢被取消或發生了一些情況 - 我想手動啓動hitTest:withEvent,然後返回不同的視圖來照顧發生的相同事件/觸摸順序。這是必要的,因爲手勢識別器僅在hitTest:withEvent返回手勢視圖並且其狀態更改爲began之後才啓動。

我不知道如何做到這一點 - 我想到了我的子視圖

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{ 

} 
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 
{ 

} 
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 
{ 

} 
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event 
{ 

} 

手動調用,但我沒有事件參數(姿態接受了它)

回答

0

我覺得這無法完成,將觸摸事件傳遞給UIGestureRecognizer是私有API。但是,您可以將觸摸事件傳遞給您喜歡的任何視圖並進行自己的手勢識別。

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    UIView* selectView = [self _findMatchView]; 
    // maybe convert touches to selectView coordinate 
    [selectView handleTouchBegan:touches withEvent:event]; 
}