Reputation: 777
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:
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
Upvotes: 5
Views: 3716
Reputation: 11607
Did you perhaps forgot to go:
myTextView.delegate = self;
?
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.
Upvotes: 7
Reputation: 1930
@Albert Zhang, "textViewShouldBeginEditing" will be called only when your textview becomes first responder. You can force it by doing the following.
- (IBAction)onSwitch:(id)sender{
self.textView.editable = self.editableSwitch.on;
if(self.textView.editable)
{
[[self textView]becomeFirstResponder];
}
}
Upvotes: 0