I have a form about the size of the screen height and am trying to resize the scroll view's frame when the keyboard pops up, which works just fine. Found a lot of great tutorials on that. But after the keyboard pops up I can only click the first 4 fields (coincidentally the ones above the keyboard). I can still use tab to navigate to the lower ones and click them before the keyboard pops up, but I can't scroll to a lower text field and click on it.
I'm not doing much code at all, but I can't tell why it would do this.
- (void) makeRoomForKeyboard:(NSNotification *)notif {
float keyboardHeight = [[[notif userInfo] objectForKey:UIKeyboardBoundsUserInfoKey] CGRectValue].size.height;
scrollForm.frame = CGRectMake(0, 0, scrollForm.frame.size.width, windowHeight-keyboardHeight);
}
I put one of the fields that wasn't working higher up where the good fields are and it again worked fine. I'm guessing there's a rect or something that I'm n开发者_开发问答ot setting that triggers the touch event or something.
Don't change the scrollForm frame, instead set the bottom contentInset.
I think you need to resize the UIScrollView's content area in addition to adjusting the frame.
If your UIScrollView was originally the correct size to display all the content without scrolling, you could say something like this:
scrollForm.contentSize = scrollForm.frame.size;
scrollForm.frame = CGRectMake(0, 0, scrollForm.frame.size.width, windowHeight-keyboardHeight);
That should allow you to scroll to the area of the scroll view covered by the keyboard.
精彩评论