te')); return $arr; } /* 遍历用户所有主题 * @param $uid 用户ID * @param int $page 页数 * @param int $pagesize 每页记录条数 * @param bool $desc 排序方式 TRUE降序 FALSE升序 * @param string $key 返回的数组用那一列的值作为 key * @param array $col 查询哪些列 */ function thread_tid_find_by_uid($uid, $page = 1, $pagesize = 1000, $desc = TRUE, $key = 'tid', $col = array()) { if (empty($uid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('uid' => $uid), array('tid' => $orderby), $page, $pagesize, $key, $col); return $arr; } // 遍历栏目下tid 支持数组 $fid = array(1,2,3) function thread_tid_find_by_fid($fid, $page = 1, $pagesize = 1000, $desc = TRUE) { if (empty($fid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('fid' => $fid), array('tid' => $orderby), $page, $pagesize, 'tid', array('tid', 'verify_date')); return $arr; } function thread_tid_delete($tid) { if (empty($tid)) return FALSE; $r = thread_tid__delete(array('tid' => $tid)); return $r; } function thread_tid_count() { $n = thread_tid__count(); return $n; } // 统计用户主题数 大数量下严谨使用非主键统计 function thread_uid_count($uid) { $n = thread_tid__count(array('uid' => $uid)); return $n; } // 统计栏目主题数 大数量下严谨使用非主键统计 function thread_fid_count($fid) { $n = thread_tid__count(array('fid' => $fid)); return $n; } ?>javascript - CordovaPhonegap 3.4.0 iOS 7.1 - KeyboardWeb View issue - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - CordovaPhonegap 3.4.0 iOS 7.1 - KeyboardWeb View issue - Stack Overflow

programmeradmin3浏览0评论

I've been struggling with this issue for over a week now and would really appreciate any help I can get. I'll explain the issue as I understand it but please correct if I say anything incorrect.

In iOS 7.0.x, when the keyboard became revealed, the web view was resized so that the area that the keyboard took was not considered part of the viewport window size. Up until 7.0, the Cordova Keyboard plugin handled this web view resizing. Since 7.0 natively handled the keyboard reveal in the desired way, the Keyboard shrinkView option for the config.xml file became a "No-op" as of this mit:

However, in 7.1, the area the keyboard occupies es up over the web view. This has a painful side-effect. Say you want to prepend a <div> to the body with a textarea area (like leaving a ment or chat reply), ie;

<body>
  <div id="app">...</div>
  <div id="reply">
    <textarea></textarea>
  </div>
</body>

example CSS:

body {
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  left: 0;
  overflow: hidden;
}
#reply {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
}

Whenever you focus or input into the textarea, the web view will natively re-center the input field. Since the web view still takes the entire height of the screen into account, the div will not stay fixed to the bottom and thus breaks the layout.

I've tried the following things:

  • Futzing with the CSS for the body and fixed div. Position fixed/absolute doesn't seem to make a difference. Setting an explicit height to the body does nothing.

  • All possible binations of meta viewport options. This is what I'm currently using:

<meta name="viewport" content="user-scalable=no, initial-scale=1, minimum-scale=1, maximum-scale=1, width=device-width, height=device-height, minimal-ui" />

  • Unmenting the "No-op" in the cordova keyboard plugin. This still breaks the layout as it did in iOS 7.0.x.

  • Having JS event listeners on the input and focus events to keep calculating the bottom offset to keep the div at the bottom. This is very jumpy because its battling the native web view behavior of centering the input field.

  • Altering the meta tag to set an explicit height after the keyboard is shown/hidden.

I'm using Cordova 3.4.0-0.1.3

Has anyone else experienced this issue? Any solutions or ideas?

I've been struggling with this issue for over a week now and would really appreciate any help I can get. I'll explain the issue as I understand it but please correct if I say anything incorrect.

In iOS 7.0.x, when the keyboard became revealed, the web view was resized so that the area that the keyboard took was not considered part of the viewport window size. Up until 7.0, the Cordova Keyboard plugin handled this web view resizing. Since 7.0 natively handled the keyboard reveal in the desired way, the Keyboard shrinkView option for the config.xml file became a "No-op" as of this mit:

https://github./apache/cordova-plugins/mit/20215013bf91b659b73d5f428ae91dd58be1273a

However, in 7.1, the area the keyboard occupies es up over the web view. This has a painful side-effect. Say you want to prepend a <div> to the body with a textarea area (like leaving a ment or chat reply), ie;

<body>
  <div id="app">...</div>
  <div id="reply">
    <textarea></textarea>
  </div>
</body>

example CSS:

body {
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  left: 0;
  overflow: hidden;
}
#reply {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
}

Whenever you focus or input into the textarea, the web view will natively re-center the input field. Since the web view still takes the entire height of the screen into account, the div will not stay fixed to the bottom and thus breaks the layout.

I've tried the following things:

  • Futzing with the CSS for the body and fixed div. Position fixed/absolute doesn't seem to make a difference. Setting an explicit height to the body does nothing.

  • All possible binations of meta viewport options. This is what I'm currently using:

<meta name="viewport" content="user-scalable=no, initial-scale=1, minimum-scale=1, maximum-scale=1, width=device-width, height=device-height, minimal-ui" />

  • Unmenting the "No-op" in the cordova keyboard plugin. This still breaks the layout as it did in iOS 7.0.x.

  • Having JS event listeners on the input and focus events to keep calculating the bottom offset to keep the div at the bottom. This is very jumpy because its battling the native web view behavior of centering the input field.

  • Altering the meta tag to set an explicit height after the keyboard is shown/hidden.

I'm using Cordova 3.4.0-0.1.3

Has anyone else experienced this issue? Any solutions or ideas?

Share Improve this question asked Mar 31, 2014 at 22:50 waymondowaymondo 3353 silver badges9 bronze badges 1
  • How you found any solution to this problem yet? – Saad Bashir Commented Jun 11, 2014 at 11:14
Add a ment  | 

4 Answers 4

Reset to default 2

A quick fix for me involved forcing the window to scroll back into position when the input looses focus:

$("input").on('blur',function(){

 //set brief timeout to let window catch up
 setTimout(function(){

   //reposition at top left corner of screen
   window.scrollTo(0,0);

 },20); 

});

Hope that helps!

It looks like Ionic has a multipart solution to this problem which includes dynamically updating the meta viewport tag depending on the device and also by hooking into the keyboard hide/show event and then using their scrolling framework to scroll the input into view.

More info here.. http://ionicframework./blog/ionic-keyboard/

This requires you to use their framework so I'm in the process of porting this over to JQuery and IScroll and I'll keep you updated on my progress.

I also posted my experiences with the phonegap keyboard on the phonegap forum but have not had much response yet. https://groups.google./forum/#!topic/phonegap/LE9-lIsNT2c

I am experiencing somewhat similar issue. I have a cordova 3.3.0 app in bination with Sencha Touch.

The problem I was facing before iOS 7.0 was that the title bar went beyond the top of screen when the keyboard came up. The keyboard simply used to push the whole viewport up. After a lot of search and hard work, I was able to partially fix the issue by implementing a counter animation to move the title bar down while the keyboard was rising, using the focus and blur events of the textfield.

iOS 7.0 came as a happy surprise as it fixed this issue natively. I mented out my fix (fortunately, did not delete) and the title bar remained fixed at the top without any extra effort.

It seems iOS 7.1 has reverted that fix (wonder why??). When I updated to iOS 7.1, the title bar issue returned and I have now no choice but to unment the clumsy fix. Can anybody give some better or permanent solution to fix this problem?

Does this solve your issue?

Check your html meta tags for something like this:

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

Replace it with this:

<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, target-densityDpi=device-dpi" />
发布评论

评论列表(0)

  1. 暂无评论