My problem is that none of the delegate methods of UITextView get called.
My code, I've not included the whole class, just the relevant parts. I'm not using an XIB, its all added programatically. None of my delegate methods get called.
.h
@interface ChatAppViewController : UIViewController <UITableViewDelegate,
UITableViewDataSource, UITextViewDelegate>
{
UITextView * messageTextField;
}
.m
- (void)viewDidLoad
{
messageTextField = [[UITextField alloc] initWithFrame:CGRectMake(5, 408, 310, 70)];
messageTextField.textColor = [UIColor blackColor]; //text color
messageTextField.font = [UIFont systemFontOfSize:17.0]; //font size
[messageTextField setPlaceholder:@"Post a message" ];
messageTextField.backgroundColor = [UIColor whiteColor]; //background color
messageTextField.autocorrectionType = UITextAutocorrectionTypeNo;
messageTextField.keyboardType = UIKeyboardTypeDefault; // type of the keyboard
messageTextField.returnKeyType = UIReturnKeyDone; // type of the return key
messageTextField.delegate = self;
messageTextField.hidden = NO;
[self.view addSubview:messageTextField];
}
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView {
NSLog(@"textViewShouldBeginEditing");
return YES;
}
- (void)textViewDidBeginEditing:(UITextView *)textView {
NSLog(@"textViewDidBeginEditing");
}
- (void)textViewDidChange:(UITextView *)textView {
NSLog(@"textViewDidChange");
}
- (void)textViewDidChangeSelection:(UITextView *)textView {
NSLog(@"textViewDidChangeSelection");
}
- (BOOL)textViewShouldEndEditing:(UITextView *)textView {
NSLog(@"textViewShouldEndEditing");
return YES;
}
- (void)textViewDidEndEditing:(UITextView *)textView {
NSLog(@"textViewDidEndEditing");
}
Many Thanks, -Code