I have a UITableView with cells that contain a UILabel. When I tap the UILabel, I'd want to execute an action, therefore I added a UITapGestureRecognizer.
UILabel *telephone = (UILabel *)[cell.contentView viewWithTag:420];
telephone.userInteractionEnabled = YES;
UITapGestureRecognizer *tapToCall = [[UITapGestureRecognizer alloc] initWithTarget:telephone action:@selector(tapToCall:)];
[telephone addGestureRecognizer:tapToCall];
Then I defined the selector method:
-(void)tapToCall: (UITapGestureRecognizer*) sender {
UILabel *telephone = (UILabel *) sender.view;
NSLog(@"%@", telephone.text);
}
But now I receive an error when I touch the 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'
What did I do wrong here?