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
イベントを取得しないようです。
何か案は?