7

It looks like the Safari keyboard works like this on iPads...

  • If the webpage originally reaches the bottom of the screen, when the keyboard appears it never scrolls past the bottom of the webpage.

  • If the webpage originally doesn't reach the bottom of the screen and the textfield that has the focus is more than halfway down the screen, it scrolls the webpage so that the current textfield is now halfway down the screen and doesn't care if the area below the original webpage is showing.

Basically I want to have a webpage that doesn't fill the screen vertically and yet I don't want the keyboard to cause the screen to scroll past the bottom of the webpage because that would hide the top part of the webpage and instead show the blank area below the webpage.

In portrait mode on an iPad the following webpage is always showing even when a textfield is active and the keyboard is showing: http://sky-walker.net/temp/ipad/a

But when you view that webpage in landscape mode and select the bottom textfield, the webpage scrolls so that the bottom textfield is halfway up the screen. I want it to be at the bottom of the screen.

http://sky-walker.net/temp/ipad/b

In landscape mode the previous link fills the entire screen and so if you click on the bottom textfield (after scrolling) the textfield appears at the bottom of the screen when the keyboard is visible rather than the screen scrolling until the textfield is halfway down the screen.

In portrait mode the previous link doesn't originally fill the screen so if you click on the bottom textfield (making the keyboard appear) it scrolls up so that it is halfway up the screen.

http://sky-walker.net/temp/ipad/d The final link fills the entire screen for portrait mode as well and when the bottom textfield is selected it doesnt scroll past the bottom of the webpage when the keyboard becomes visible.

Maybe what it is doing when the webpage isn't filling the screen is that it is remembering the empty space at the bottom and then it scrolls up (hiding the top) when the keyboard is visible. I want it to forget about the empty space at the bottom when the keyboard appears.

Luke Wenke
  • 1,149
  • 2
  • 23
  • 43

1 Answers1

0

I faced a very similar issue. Here's what I do.

I subscribe to UIKeyboardWillShowNotification to get the keyboard size then when the scroll view scrolls up more than the keyboard height then I set the scroll offset to the keyboard height.

François
  • 3,164
  • 25
  • 58