Last active
August 29, 2015 14:03
-
-
Save sanketfirodiya/52881274e3da868b697f to your computer and use it in GitHub Desktop.
Scroll up UITableView when keyboard is shown
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)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