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

后端 未结 10 1449
萌比男神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:31

    The way Dinesh suggested will work without the for loop using the property variable.

    UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)];
    [tap setNumberOfTapsRequired:1];
    [self.myUILabel addGestureRecognizer:tap];
    

提交回复
热议问题