开发者

UITextView intercept calls to setSelectedRange?

开发者 https://www.devze.com 2023-02-07 21:32 出处:网络
If you tap a UITextView, the selectedRange property is set.I want to intercept that call and possi开发者_如何学Gobly change the location.Is there any way to do that?

If you tap a UITextView, the selectedRange property is set. I want to intercept that call and possi开发者_如何学Gobly change the location. Is there any way to do that?

I tried implementing

-(void) setSelectedRange: (NSRange) theRange 

in my subclass. This intercepts it just fine if I am setting the range. But if Apple's code is doing the setting (as happens with a tap), my subclass setSelectedRange method does not fire.

Thanks


Instances of UITextView send a -textViewDidChangeSelection: notification to their delegate whenever the selection changes, so you could implement that in your controller (don't forget to make it the text view's delegate of course), and have the controller manipulate the selectedRange property itself.

0

精彩评论

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