Created
January 3, 2014 19:21
-
-
Save aug2uag/8244608 to your computer and use it in GitHub Desktop.
move keyboard
delegate for UITextView
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (void)textViewDidBeginEditing:(UITextView *)textView | |
| { | |
| [self animateTextView:textView up: YES]; | |
| } | |
| - (void)textViewDidEndEditing:(UITextView *)textView | |
| { | |
| [self animateTextView:textView up:NO]; | |
| } | |
| - (void) animateTextView:(BOOL) up | |
| { | |
| const int movementDistance =heightKeyboard; // tweak as needed | |
| const float movementDuration = 0.3f; // tweak as needed | |
| int movement= movement = (up ? -movementDistance : movementDistance); | |
| NSLog(@"%d",movement); | |
| [UIView beginAnimations: @"anim" context: nil]; | |
| [UIView setAnimationBeginsFromCurrentState: YES]; | |
| [UIView setAnimationDuration: movementDuration]; | |
| self.view.frame = CGRectOffset(self.inputView.frame, 0, movement); | |
| [UIView commitAnimations]; | |
| } | |
| /* | |
| from StackOverflow: | |
| http://stackoverflow.com/a/18224787/1546710 | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment