문제

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.

도움이 되었습니까?

해결책 2

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.

다른 팁

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.

I think you'll have to subclass UITextView and implement touchesEnded:withEvent: in order to know when the user stops changing the selection.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top