简体   繁体   中英

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.

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.

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.

我认为你必须touchesEnded:withEvent: UITextView并实现touchesEnded:withEvent:以便知道用户何时停止更改选择。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM