Skip to content

Instantly share code, notes, and snippets.

@sanketfirodiya
Last active August 29, 2015 14:03
Show Gist options
  • Save sanketfirodiya/52881274e3da868b697f to your computer and use it in GitHub Desktop.
Save sanketfirodiya/52881274e3da868b697f to your computer and use it in GitHub Desktop.
Scroll up UITableView when keyboard is shown
- (void)keyboardWillBeShown:(NSNotification*)aNotification{
CGFloat mainViewScrollUp;
NSDictionary* info = [aNotification userInfo];
CGSize keyboardSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
mainViewScrollUp = keyboardSize.height;
UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0, keyboardSize.height, 0.0);
self.uiTableView.contentInset = contentInsets;
self.uiTableView.scrollIndicatorInsets = contentInsets;
CGPoint scrollPoint = CGPointMake(0.0, mainViewScrollUp);
[UIView animateWithDuration:0.01f
animations:^{
[self.uiTableView setContentOffset:scrollPoint animated:YES];
}
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment