UITextViewDelegate methods not being called (UITextView within UITableViewCell)

ToddB picture ToddB · Sep 27, 2012 · Viewed 15.4k times · Source

I must be doing something fundamentally wrong, my implementation methods for the UITextViewDelegate aren't firing. I have a UITextView that is a subview of a UITableCellView and the delegates aren't being called.

- (void)textViewDidBeginEditing:(UITextView *)textView {

    NSLog(@"textViewDidBeginEditing");
    // never called...
}

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {

    NSLog(@"shouldChangeTextInRange");  
    // never called... 
}

Suggestions? I don't know whether it matters, but the protocol is explicitly named in my @interface declaration.

@interface DetailViewController () <UITextViewDelgate, ..., ....>

Thanks!

Answer

Ganesh G picture Ganesh G · Sep 27, 2012

You should add the textViewObj.delegate = self or give delegate connection for that text view property in xib file, then it should work and fire all delegate methods of UITextView.