开发者

Resetting the selection cursor in a UITextView

开发者 https://www.devze.com 2023-03-18 14:36 出处:网络
I\'ve looked at similarly titled questions, such as : UITextView disabling text selection but that wasn\'t quite what I was trying to achieve.

I've looked at similarly titled questions, such as :

UITextView disabling text selection

but that wasn't quite what I was trying to achieve.

My app has a UITextView that only requires vertical scrolling. When holding down a touch, the cursor obviously appears at the point of the touch. However, when I change the text of the view, the cursor is always put at the end of the UITextView, which of course scrolls my text all the way to the bottom. I've tried setting the selected range, but even with the editable set to NO, this causes the keyboard to popup. I want my view to be able to display my text and vertically scroll, and to be able to reset its 开发者_运维技巧scroll position when I change the text. If I could achieve this and not be able to select, copy, paste, edit, etc. I would be perfectly content.

The last time I tried to deal with this I gave up and ended up using a UILabel, however I need to be able to scroll this time around. Would I be better off putting a UILabel inside a scroll view as a work around? Or perhaps releasing the textView would work, but since I have it hooked as a referencing outlet in IB, I imagine I would have to recreate it programmatically, and I'd like to avoid something so hacky if I can.

I'm at my whit's end with something I've always felt should be simple, so thanks in advance for any and all help!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号