我有一个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