Created
July 2, 2012 16:46
-
-
Save meiwin/3034192 to your computer and use it in GitHub Desktop.
resizing view on keyboard apperance/disapperance
This file contains 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
#pragma mark - Handle Keyboard Appearance/Disappearance | |
- (void)keyboardWasShown:(NSNotification*)aNotification | |
{ | |
NSDictionary* info = [aNotification userInfo]; | |
CGRect kbRect = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue]; | |
kbRect = [self.view convertRect:kbRect toView:nil]; | |
CGRect viewRect = [self.view convertRect:self.view.frame fromView:nil]; | |
CGRect newRect = CGRectMake(viewRect.origin.x | |
,viewRect.origin.y | |
,viewRect.size.width | |
,viewRect.size.height-kbRect.size.height); | |
self.view.frame = [self.view convertRect:newRect toView:nil]; | |
} | |
- (void)keyboardWillBeHidden:(NSNotification*)aNotification { | |
NSDictionary* info = [aNotification userInfo]; | |
CGRect kbRect = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue]; | |
kbRect = [self.view convertRect:kbRect toView:nil]; | |
CGRect viewRect = [self.view convertRect:self.view.frame fromView:nil]; | |
CGRect newRect = CGRectMake(viewRect.origin.x | |
,viewRect.origin.y | |
,viewRect.size.width | |
,viewRect.size.height+kbRect.size.height); | |
self.view.frame = [self.view convertRect:newRect toView:nil]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment