2012-02-16 41 views
2

之外時潤色我有一個UIView,而我想知道當用戶在做:UIGestureRecognizer抵消的TargetView

touchDownInside(突出視圖)

touchUpInside(確認操作)

touchUpOutside(取消並重置hightlight)

什麼gestureRecognizer能爲我做到這一點?

回答

2

請到雖然這四種方法也該視圖可以覆蓋到處理四個不同的觸摸事件:

1)一個或多個手指觸摸屏幕

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

2)手指或手指在移動屏幕(該消息多次,手指移動。)

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

3)手指或手指從屏幕上除去

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

4)的系統事件,中斷觸摸它結束

-(void)touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event; 
之前
0

你可以這樣做來實現觸摸方法本身,爲什麼你需要手勢識別器?

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

上述觸摸功能。

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

上述觸摸功能。和兩者的組合取消。