0

I have implemented the UITextViewDelegate in my view Controller, which needs to do something when the text selection changes in textView.

So I used textview:didChangeSelection to listen to call back events. It works on the iPhone simulator and iOS5 ,but not on iPhone4 devices. Why does that happen?

Debug information tells me that the textview:didChangeSelection isn't getting called when I change selection with range of 0 length....

- (void)textViewDidChangeSelection:(UITextView *)textView
{
    if (textView.selectedRange.location != NSNotFound) {
        selectRange = textView.selectedRange;
    }
}

Can anyone can help to fix the problem?

chatur
  • 2,365
  • 4
  • 24
  • 38
  • u sure u added the UITextViewDelegate to a VIEWCONTROLLER u use? cause i added it to class which just had the text view and i ran in to the same problem. – Prajwal Udupa Jan 28 '14 at 09:21

1 Answers1

0

Did you add UITextViewDelegate in your header file ?

AAV
  • 3,785
  • 8
  • 32
  • 59
  • yes ,i already add UITextViewDelegate in my header file,other callback functions such as textviewDidBeginEditing, textviewDidChage works well, only textViewDidChangeSelection just not getting called in ios devices – jasen huang Jan 11 '12 at 06:17
  • This is very odd. Can you restart your device, delete the app and try clean Xcode build on it ? – AAV Jan 11 '12 at 17:02
  • I've try already,it doesn't work as well.but i found it's strange that "textViewDidChangeSelection" are getting called only when i double click the textView at the same position. (only in ios4.2) – jasen huang Jan 12 '12 at 18:11