UITapGestureRecognizer working on UIImageView but not on UILabel

后端 未结 2 1005
渐次进展
渐次进展 2021-01-24 07:25

I have a UITableViewCell class named CommentsTableViewCell which among other things includes a UIImageView and a UILabel.

2条回答
  •  太阳男子
    2021-01-24 07:48

    You need different gesture for all control

    let tapGesture = UITapGestureRecognizer(target: self, action: #selector(CommentsTableViewCell.showUserViewController))
    avatarRoundImageView.userInteractionEnabled = true
    avatarRoundImageView.addGestureRecognizer(tapGesture)
    
    let tapGesture2 = UITapGestureRecognizer(target: self, action: #selector(CommentsTableViewCell.showUserViewController))
    nameLabel.userInteractionEnabled = true
    nameLabel.addGestureRecognizer(tapGesture2)
    

提交回复
热议问题