Search code examples
iphoneiosuitextviewuitextviewdelegate

UITextViewDelegate methods not being called (UITextView within UITableViewCell)


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!


Solution

  • 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.