- (void) textFieldDidBeginEditing:(UITextField *)textField
{
// [self animateTextField:textField up:YES];
[ViewControllerFactoryanimateTextField:textField up:YESviewController:self];
}
- (void) textFieldDidEndEditing:(UITextField *)textField
{
// [self animateTextField:textField up:NO];
[ViewControllerFactoryanimateTextField:textField up:NOviewController:self];
}
- (void) animateTextField: (UITextField *)textField up: (BOOL)up
{
const int movementDistance = -textField.tag;
const float movementDuration = 0.3f;
int movement = (up ? movementDistance: -movementDistance);
[UIViewbeginAnimations:@"animateTextField"context:nil];
[UIViewsetAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:movementDuration];
self.view.frame = CGRectOffset(self.view.frame, 0, movement);
[UIViewcommitAnimations];
}