Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITextView did finish change selection

I want to catch event when user finish change selection in UITextView. Method textViewDidChangeSelection: call a few times while user pulls cursor. I try to use touchesEnded:withEvent:, but it doesn't call. Try to add pan gesture, but pan handler don't call.

like image 999
Gralex Avatar asked Mar 21 '23 16:03

Gralex


2 Answers

I know it's too late to answer. Though.. You can use selectedRange inside textViewDidChangeSelection: and check if selectedRange.length is greater than zero. This will confirm that user has selected something and not just moved the cursor.

like image 78
Nikhil Manapure Avatar answered Apr 02 '23 13:04

Nikhil Manapure


UITextInputDelegate's selectionDidChange(_:) is called when the user has finished changing the selection (lifts their finger from the selection handles). On the UITextView, set your class as the inputDelegate. This works for read-only text views, not just editable ones.

like image 38
Adam Preble Avatar answered Apr 02 '23 13:04

Adam Preble