I have a UITextView that has its delegate set to my view controller
I would like to your help in figuring out how to find out, through delegate methods, subclassing, selectors and what not, when the cursor is moved.
I've tried -textViewDidChange
and -textViewDidChangeSelection
among all other delegate methods but they don't get called when the cursor was moved within the textview...
So how can I discover when the caret is moved in my UITextView
and act upon it as necessary(run some code)
This may seem like an unpractical question but I have a scenario where I need to update a label when the cursor is moved up or down so I would like to fig
Thanks, I hope I've been as clear as possible
Just to expand on @rmaddy's comment. You'll want to use the UITextViewDelegate
method -textViewDidChangeSelection: to be notified when the selected range in the text view changes. From there, you can access the NSRange representing the selection of text via the text view's selectedRange
property.
- (void)textViewDidChangeSelection:(UITextView *)textView
{
NSRange range = textView.selectedRange;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With