1

I am developing an iOS app in phonegap / cordova 3.3.0 with jquery mobile 1.4.2
I have designed a page with multiple textboxes for input but when iPhones native keyboard opens it pushes page up in iphone 4, in an iphone 5 also i face same issue but page comes to original state after closing keyboard, but in iphone 4 page stucks at the top in pushed position. Check screen shots below. enter image description here
this is screen
this is when keyboard open enter image description here


after closing keyboard is closed enter image description here
please help...

Sushant
  • 391
  • 12
  • 28
  • 1
    possible duplicate of [PhoneGap Page scroll up after Keyboard appearance in iOS devices that makes the PhoneGap page corrupted](http://stackoverflow.com/questions/15000660/phonegap-page-scroll-up-after-keyboard-appearance-in-ios-devices-that-makes-the) – byJeevan Jun 24 '14 at 05:30
  • @jeekonline, thanks buddy. This link helped. – Sushant Jun 24 '14 at 06:50

4 Answers4

2

For now you can add a:

document.body.scrollTop = 0;

whenever the input field fires a blur event.

courtesy: link

Community
  • 1
  • 1
Sushant
  • 391
  • 12
  • 28
1

Not sure if it's relevant anymore, but i will add it anyway cause it fix my issue, i just added:

  window.addEventListener('native.keyboardhide', function(){
                            window.scrollTo(0,0);
                        });

and it solves my issue.

Liad Livnat
  • 7,435
  • 16
  • 60
  • 98
0

I came across similar situations but I need to keep the focused field at bottom. Notice that I cater the situations for different iphone models based on the window size.

  function fixKeyboardOffset(){
    var iOSOffset = 0;
    switch ($(window).height()){
      case 716 : iOSOffset = 340; break;
      case 647 : iOSOffset = 285; break; 
      case 548 : iOSOffset = 190; break;  
      case 460 : iOSOffset = 110; break;  
    }
    if (device.platform == 'iOS'){
        $('#comment-field').on('focus', function(e) {
          $('html, body').animate({
              scrollTop: $("#content_comment_container").offset().top - iOSOffset
          }, 0);
        });
    }
  }
eric-haibin-lin
  • 377
  • 2
  • 9
-1

Try to add:

  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

This is how I solved same issue in phonegap build.

byJeevan
  • 3,728
  • 3
  • 37
  • 60