У меня есть UITextField, который я сделал здесь:
text_field = [[UITextField alloc] initWithFrame:CGRectMake(10, 8, 260, 40)];
text_field.delegate = [[MessageInputDelegate alloc] init];
Реализация делегата:
@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
Это работает при первой активации текстового поля, но не во второй раз...?
Спасибо.