我对 UIGestureRecognizer 有一个奇怪的问题
我创建了一个类,我在其中声明手势识别器,并将 self 作为目标
-(id)initWithTextView:(UITextView*)theTextView withDelegate:(id<WordSelectionDelegate>)theDelegate
{
if (self = [super init])
{
delegate = theDelegate;
textView = theTextView;
// init long press gesture to detect pressing on text elements
UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPressFromSender:)];
[textView addGestureRecognizer:longPressGesture];
}
return self;
}
但诀窍是当我真正做出长按手势时,我有下一个错误:
*由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[NSConcreteMutableAttributedString handleLongPressFromSender:]:无法识别的选择器发送到实例 0x76227b0”
为什么给自己的消息会转到字符串???