1
votes

I want to know the selecedRange of UITextView, I use the delegate method testViewDidChangeSelection. The problem is this method only called when I change selection, but if I tap and hold on textView, the magnifying glass appears and will also select some text without call this function. In my case, my textview is not editable, user can only select and copy. I want to know how can I know magnifying glasses is dismissed, so that I can get the selected text info. Or is there any other way to achieve this?

Thank you guys who helped me to analyze this problem, and finally I find the solution. My real problem is when I rotate my device, the selection is lost. During the rotation, I redraw the textView as well as reset its text. When we reset the text of UItextview, its property selectedRange will be reset too, that's why the selection is lost. Thank you jimpic and NobleK :)

1
I just tried it, the delegate method is always called. Can you explain in detail what you are doing so the method is not called?jimpic
I tap and hold on the textViewer, then the magnifying glass will appear, then I release the hold, the there will be some text being selected right? but the testViewDidChangeSelection method hasn't been calledCharlesjean
no there will be no text selected, but the method is still called with the updated position of the cursor.jimpic
you can tap on an area, not just a point, if your finger covers a word, the word will be selected. you can test using Notes app.Charlesjean
when you hold don't move the finger, so there's no cursor position changing.Charlesjean

1 Answers

0
votes

Thank you guys who helped me to analyze this problem, and finally I find the solution. My real problem is when I rotate my device, the selection is lost. During the rotation, I redraw the textView as well as reset its text. When we reset the text of UItextview, its property selectedRange will be reset too, that's why the selection is lost. Thank you jimpic and NobleK :)