I have a UITable
and I have multiple labels and textviews in it. I want a method to be called when touchupinside event is triggered . I used targetForAction
but i cannot specify touchUpInside
event in it.And the textview is not editable
On a whole , i want what a button does with addTarget
to be done by textview and label. Please help me
add Gesture
and try
let tap = UITapGestureRecognizer(target: self, action: #selector(self.doubleTapped(_:)))
tap.numberOfTapsRequired = 1
yourlabel.tag = indexPath.row
yourlabel.isUserInteractionEnabled = true
yourlabel.addGestureRecognizer(tap)
call method like
func doubleTapped(_ recognizer: UITapGestureRecognizer) {
print(recognizer.view!.tag)
}
for textview
add yourTextView.delegate = self
func textViewDidChange(_ textView: UITextView) {
//do continue your work
}
You can view other such methods here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With