/ Published in: Objective C
Add this code to the controller
Set controller as the delegate of the all the UITextField s in the UIView
Set controller as the delegate of the all the UITextField s in the UIView
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
- (void) animateTextField: (UITextField*) textField up: (BOOL) up{ int txtPosition = (textField.frame.origin.y - 140); const int movementDistance = (txtPosition < 0 ? 0 : txtPosition); // tweak as needed const float movementDuration = 0.3f; // tweak as needed int movement = (up ? -movementDistance : movementDistance); [UIView beginAnimations: @"anim" context: nil]; [UIView setAnimationBeginsFromCurrentState: YES]; [UIView setAnimationDuration: movementDuration]; self.view.frame = CGRectOffset(self.view.frame, 0, movement); [UIView commitAnimations]; } - (void)textFieldDidBeginEditing:(UITextField *)textField{ [self animateTextField: textField up: YES]; } - (void)textFieldDidEndEditing:(UITextField *)textField{ [self animateTextField: textField up: NO]; } - (BOOL)textFieldShouldReturn:(UITextField *)theTextField { [theTextField resignFirstResponder]; return YES; }
URL: http://yasirmturk.com/blog