Guest User

Untitled

a guest
Jul 22nd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. - (void)keyboardWillHide:(NSNotification *)n
  2. {
  3. NSDictionary *userInfo = [n userInfo];
  4. CGSize keyboardSize = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
  5.  
  6.  
  7. [UIView beginAnimations:nil context:NULL];
  8. [UIView setAnimationDuration:0.3];
  9. CGRect viewRect = [[self view] frame];
  10. viewRect.origin.y += keyboardSize.height;
  11. [[self view] setFrame:viewRect];
  12. [UIView commitAnimations];
  13. keyboardIsShown = NO;
  14. }
  15.  
  16. - (void)keyboardWillShow:(NSNotification *)n
  17. {
  18. if (keyboardIsShown) {
  19. return;
  20. }
  21. NSDictionary *userInfo = [n userInfo];
  22. CGSize keyboardSize = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
  23.  
  24. [UIView beginAnimations:nil context:NULL];
  25. [UIView setAnimationDuration:0.3];
  26. CGRect viewRect = [[self view] frame];
  27. viewRect.origin.y -= keyboardSize.height;
  28. [[self view] setFrame:viewRect];
  29. [UIView commitAnimations];
  30. keyboardIsShown = YES;
  31.  
  32. }
Add Comment
Please, Sign In to add comment