Skip to content

Instantly share code, notes, and snippets.

@joaofranca
Created July 5, 2012 00:29
Show Gist options
  • Save joaofranca/3050289 to your computer and use it in GitHub Desktop.
Save joaofranca/3050289 to your computer and use it in GitHub Desktop.
- (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