Prashanth Narasimha Prashanth Narasimha - 2 years ago 558
iOS Question

Add target to UITextView and UILabel in swift

I have a

and I have multiple labels and textviews in it. I want a method to be called when touchupinside event is triggered . I used
but i cannot specify
event in it.And the textview is not editable

On a whole , i want what a button does with
to be done by textview and label. Please help me

Answer Source

add Gesture and try

let tap = UITapGestureRecognizer(target: self, action: #selector(doubleTapped:))
tap.numberOfTapsRequired =1
yourlabel.tag = indexPath.row

call method like

func doubleTapped(recognizer: UITapGestureRecognizer) {



for textview

add yourTextView.delegate = self

func textViewDidChange(textView: UITextView) {
    //do continue your work
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download