I have a view that has text fields ranging from the top of the screen to the bottom of the screen. Obviously, the bottom text fields get covered up by the keyboard when it pops up, so I set out to get rid of this problem.
I register for notifications in the viewDidLoad
method, then when the UIKeyboardDidShowNotification
is sent, this method is called:
- (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);
scrollView.contentInset = contentInsets;
scrollView.scrollIndicatorInsets = contentInsets;
[scrollView scrollRectToVisible:activeField.frame animated:YES];
}
The problem is nothing is getting scrolled at all, let alone scrolled to visible. What am I missing here?
All of my text fields are inside of a scroll view, etc.
Thanks in advance.