- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"touchesBegan");
//test
UITouch *touch = [event allTouches] anyObject];
if ([touch tapCount] == 2) {
NSLog (@"tapcount 2");
[self.textview becomeFirstResponder];
}
else if ([touch tapCount] == 1) {
NSLog (@"tapcount 1");
[self.textview becomeFirstResponder];
[self.view performSelector:@selector(select:)];
}
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
[super touchesBegan:touches withEvent:event];
NSLog(@"touchesMoved");
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"****touchesEnded");
[self.nextResponder touchesEnded: touches withEvent:event];
NSLog(@"****touchesEnded");
[super touchesEnded:touches withEvent:event];
NSLog(@"****touchesEnded");
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{
[super touchesCancelled:touches withEvent:event];
NSLog(@"touchesCancelled");
}
我要上一个UITextView,这是该代码的TextView一次敲击时,模拟两个水龙头。但是,当我在textview上点击一次或两次时,我不会从一个和两个水龙头中获得NSLog,只能在它之外。我应该怎么做才能使它工作?
首先,这段代码必须在自定义的UITextView子类中工作,并且可能会干扰正常的操作。其次,你的意思是“我想在UITextView上敲击一次时模拟两次敲击”,我的意思是为了什么目的? – NJones
@NJones我想给用户一个选项来选择一个或两个特定功能的水龙头。我想要模拟两个水龙头来获取选定的文本,并使其只有一个水龙头用户,如果他们选择此选项。在UITextView上点击一次时是否可以强制执行两次敲击? bensnider的解决方案完美地工作。但如何模拟两个水龙头? – wagashi