Created
July 5, 2012 00:29
-
-
Save joaofranca/3050289 to your computer and use it in GitHub Desktop.
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
- (void) keyboardWillHide:(NSNotification *)nsNotification { | |
NSDictionary * userInfo = [nsNotification userInfo]; | |
CGSize kbSize = [[userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size; | |
CGRect newFrame = [tableframe]; | |
CGFloat kHeight = kbSize.height; | |
if(UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)){ | |
kHeight = kbSize.width; | |
} | |
newFrame.size.height += kHeight; | |
// save the content offset before the frame change | |
CGPoint contentOffsetBefore = table.contentOffset; | |
[table setHidden:YES]; | |
// set the new frame | |
[table setFrame:newFrame]; | |
// get the content offset after the frame change | |
CGPoint contentOffsetAfter = table.contentOffset; | |
// content offset initial state | |
[table setContentOffset:contentOffsetBefore]; | |
[table setHidden:NO]; | |
[UIView animateWithDuration:0.25 | |
animations:^{ | |
[table setContentOffset:contentOffsetAfter]; | |
} | |
completion:^(BOOL finished){ | |
// do nothing for the time being... | |
} | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment