Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent movement of user interface when keyboard appears

I'm working on a little app which uses Sencha Touch 2 for the user interface. Right now I'm running it in Safari on my iPad and iPhone.

My problem is that whenever I tap a text field, Safari brings up the virtual keyboard and pushes the whole web view upwards, off the screen.

This doesn't look very natural, since the top-toolbar is not visible anymore.

Here are two screenshots which demonstrate the problem. In the second screenshot you can see the effect when the keyboard is visible.

Is there a way to prevent this behavior, and have Safari resize the user interface instead?

Normal view


Keyboard enabled

like image 951
BastiBen Avatar asked May 16 '12 13:05

BastiBen


1 Answers

Unfortunately, Apple wants this behavior, but someone suggested a little hack using window.scrollTo():

listeners: {
    focus: function() {
        window.scrollTo(0,0);
    }
}
like image 157
Alexander Müller Avatar answered Sep 19 '22 00:09

Alexander Müller