Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

textViewShouldBeginEditing not called when not editable become to editable

I encountered a problem on the UITextFieldDelegate, anyone can help me will be great appreciate. There is a UITextView, and I implemented its delegate. Normally all delegate methods called very good. But in this case:

  1. set the UITextView not editable.
  2. long-press the UITextView until the popup appear (copy, cut, ...).
  3. dismiss the popup, and set the UITextView editable
  4. tap the UITextView to make the UITextView enter editing mode.
  5. you will find the delegate method textViewShouldBeginEditing not called.

I need the textViewShouldBeginEditing be called to handle some UI changes. Anyone knows how to solve it? Thanks very much!

Test project: I created a simple test project which will NSLog the calls of the methods, you can test my case quickly, thanks! The source code is here: http://goo.gl/tGQS5

like image 835
Albert Zhang Avatar asked Jul 25 '12 05:07

Albert Zhang


1 Answers

Did you perhaps forgot to go:

myTextView.delegate = self;

?

Extra Information

In a recent app I released, I did something similar.

I disabled a UITextField so I could use a long press gesture on a UITableViewSectionHeader to edit the section header's name, and single tap section header to select it.

I had to put:

// groupName is my UITextField
groupName.userInteractionEnabled = YES;
[groupName becomeFirstResponder];

In my long press gesture recognizer callback method.

like image 136
Zhang Avatar answered Sep 24 '22 20:09

Zhang