我有一個UITextView
,我想檢測一個水龍頭。UITextView觸發事件沒有觸發
它看起來像我會很簡單覆蓋touchesEnded:withEvent
和檢查[[touches anyObject] tapCount] == 1
,但是這個事件甚至沒有火災。
如果我覆蓋了4個事件是這樣的:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
NSLog(@"touchesBegan (tapCount:%d)", touch.tapCount);
[super touchesBegan:touches withEvent:event];
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"touches moved");
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
NSLog(@"touchesEnded (tapCount:%d)", touch.tapCount);
[super touchesEnded:touches withEvent:event];
}
-(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"touches cancelled");
}
我得到的輸出是這樣的:
> touchesBegan (tapCount:1)
> touchesCancelled
> touchesBegan (tapCount:1)
> touches moved
> touches moved
> touches moved
> touchesCancelled
我似乎從來沒有得到過touchesEnded
事件。
任何想法?
如果你把你的電話轉到超級會怎麼樣? – 2009-07-08 04:06:09
我已經做了類似的UITextView子類來檢測單擊和雙擊 - 它在2.x設備上完美工作,但不在3.0上。 – 2009-07-08 04:21:47
@Reed我希望你的文本視圖不會滾動然後。 – 2009-07-08 04:28:55