如何在不阻止textView触摸的情况下向所有UIGestureRecognizer
添加一个UITextView
..
我想在任何人触摸任何UITextView时调用方法。请任何人给我答案。
答案 0 :(得分:3)
<UITextFieldDelegate>
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
答案 1 :(得分:2)
只需使用UITextFieldDelegate
方法或在UIView
下添加UITextField
,然后将手势识别器添加到UIView
答案 2 :(得分:1)
试试这样:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"touchesBegan");
}
然后在上面的操作中处理以下方法
[super touchesBegan:touches withEvent:event];
你的整体解决方案就像这样:
#import "YourTextView.h"
@implementation YourTextView
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[super touchesBegan:touches withEvent:event];
NSLog(@"touchesBegan");
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"touchesEnded");
[self.nextResponder touchesEnded: touches withEvent:event];
NSLog(@"touchesEnded");
[super touchesEnded:touches withEvent:event];
NSLog(@"touchesEnded");
}
我希望这对你有用.. :))
答案 3 :(得分:1)
使用此代码,这是委托
<UITextFieldDelegate>
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
答案 4 :(得分:1)
首先你必须添加uitextfield
代表
<UITextFieldDelegate>
然后使用该方法
(BOOL)textFieldShouldBeginEditing:(UITextField *) textField