Find out when cursor is moved (UITextView)

前端 未结 1 1942
梦谈多话
梦谈多话 2021-01-12 01:09

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,

相关标签:
1条回答
  • 2021-01-12 01:23

    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;
    }
    
    0 讨论(0)
提交回复
热议问题