【发布时间】:2017-03-07 12:22:44
【问题描述】:
我有一个包含 UILabel 的单元格的 UITableView。当我点击 UILabel 时,我想执行一个动作,因此我添加了一个 UITapGestureRecognizer。
UILabel *telephone = (UILabel *)[cell.contentView viewWithTag:420];
telephone.userInteractionEnabled = YES;
UITapGestureRecognizer *tapToCall = [[UITapGestureRecognizer alloc] initWithTarget:telephone action:@selector(tapToCall:)];
[telephone addGestureRecognizer:tapToCall];
然后我定义了选择器方法:
-(void)tapToCall: (UITapGestureRecognizer*) sender {
UILabel *telephone = (UILabel *) sender.view;
NSLog(@"%@", telephone.text);
}
但现在我在触摸 UILabel 时收到错误消息:
2017-03-07 13:17:49.220 [37354:2794848] -[UILabel tapToCall:]: unrecognized selector sent to instance 0x7fc39f459250
2017-03-07 13:17:49.253 [37354:2794848] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UILabel tapToCall:]: unrecognized selector sent to instance 0x7fc39f459250'
我在这里做错了什么?
【问题讨论】:
标签: ios objective-c uitableview uilabel uitapgesturerecognizer