Skip to content

Instantly share code, notes, and snippets.

@aug2uag
Created January 3, 2014 19:21
Show Gist options
  • Select an option

  • Save aug2uag/8244608 to your computer and use it in GitHub Desktop.

Select an option

Save aug2uag/8244608 to your computer and use it in GitHub Desktop.
move keyboard delegate for UITextView
- (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