Find out when the cursor moves (UITextView)

I have a UITextView that has its delegate installed on my view controller

I would like to help you figure out how to find out through delegation methods, subclasses, a selector, and what doesn't when the cursor moves.

I tried -textViewDidChange and -textViewDidChangeSelection among all other delegate methods, but they are not called when moving the cursor in text form ...

So, how can I find out when the carriage moves in my UITextView and act as needed (run some code)

This may seem like an impractical question, but I have a scenario where I need to update the label when the cursor is moved up or down, so I would like to set

Thank you, I hope I was as clear as possible.

+8
ios uitextview
source share
1 answer

Just to enlarge @rmaddy's comment. You will want to use the UITextViewDelegate -textViewDidChangeSelection: method to receive notifications when the selected range in the text view changes. From there, you can access NSRange by presenting a selection of text through a textual representation of selectedRange .

 - (void)textViewDidChangeSelection:(UITextView *)textView { NSRange range = textView.selectedRange; } 
+13
source share

All Articles