ios - UITapGestureRecognizer working on UIImageView but not on UILabel -
i have uitableviewcell
class named commentstableviewcell
among other things includes uiimageview
, uilabel
.
code i'm using:
let tapgesture = uitapgesturerecognizer(target: self, action: #selector(commentstableviewcell.showuserviewcontroller)) namelabel.userinteractionenabled = true avatarroundimageview.userinteractionenabled = true namelabel.addgesturerecognizer(tapgesture) avatarroundimageview.addgesturerecognizer(tapgesture)
as can understand have function shows uiviewcontroller
whenever uiimageview
or uilabel
tapped.
what buffles me tapgesture
works correctly on uiimageview
not on uilabel
.
any ideas?
you need different gesture 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)
Comments
Post a Comment