我有一个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
事件。
有任何想法吗?