Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have `textViews` in a `tableView`. When `textViews` (towards the bottom of the `tableView`) get selected the keyboard pops up, and hides the `textView`, and you can't scroll down either. So I added the following code:

Objective-C
- (void)keyboardWasShown:(NSNotification*)aNotification
{
    NSDictionary* info = [aNotification userInfo];
    CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;

    UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0, kbSize.height, 0.0);
    myTableView.contentInset = contentInsets;
    myTableView.scrollIndicatorInsets = contentInsets;

    CGRect aRect = self.view.frame;
    aRect.size.height -= kbSize.height;
    if (!CGRectContainsPoint(aRect, activeField.frame.origin) ) {
        [self.myTabelView scrollRectToVisible:activeField.frame animated:YES];
    }
}


I now have the opposite problem. When the keyboard does show, everything on top doesn't show, and it's not possible to scroll all the way up either.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900