I have a UITextField which I made here:
text_field = [[UITextField alloc] initWithFrame:CGRectMake(10, 8, 260, 40)];
text_field.delegate = [[MessageInputDelegate alloc] init];
The delegate implementation:
@implementation MessageInputDelegate
- (BOOL) textFieldShouldReturn: (UITextField *) text_field{
[the_view5 becomeFirstResponder];
the_view5->text_area.frame = CGRectMake(20, 320, 280, 40);
the_view5->message_label.frame = CGRectMake(0, 0, 320, 320);
text_field.enabled = NO;
text_field.text = @"";
return YES;
}
- (void) textFieldDidBeginEditing: (UITextField *) textField{
printf("DID CALL EDIT METHOD\n");
the_view5->text_area.frame = CGRectMake(20, 140, 280, 40);
the_view5->message_label.frame = CGRectMake(0, 0, 320, 140);
}
- (BOOL) textField: (UITextField *) textField shouldChangeCharactersInRange: (NSRange) range replacementString: (NSString *) string{
if (textField.text.length >= 400 && range.length == 0){
return NO;
}
return YES;
}
@end
It works the first time I activate the text field but not the second time...?
Thankyou.
I used endEditing to close the keyboard and it works.