How can I add a UITapGestureRecognizer to a UILabel inside a table view cell?

后端 未结 10 1576
萌比男神i
萌比男神i 2021-02-04 00:43

I am using a NIB file to layout a custom table view cell. This cell has a label with outlet called lblName. Adding a UITapGestureRecognizer to this label never fires the assoc

10条回答
  •  没有蜡笔的小新
    2021-02-04 01:30

    UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)]; 
    [recognizer setNumberOfTapsRequired:1];
    lblName.userInteractionEnabled = YES;  
    [lblName addGestureRecognizer:recognizer];
    

提交回复
热议问题