位于虚拟键盘下方的iOS 7.1输入字段会强制缩放焦点

Joe*_*ora 15 javascript ios cordova ionic-framework ios7.1

我正在使用Cordova编写聊天应用程序,聊天视图在页面底部有一个类似iMessage的输入字段.在iOS 7.0中,单击该字段会调整窗口大小并将输入字段放在键盘上方.在iOS 7.1中,单击输入字段只是从底部向上推动所有内容,并且不会调整窗口大小.

我的视口设置为:

<meta name="viewport" content="user-scalable=no, initial-scale=1, minimum-scale=1, maximum-scale=1, target-densitydpi=device-dpi" />
Run Code Online (Sandbox Code Playgroud)
  • 将输入相对于顶部定位时,不会发生调整大小.但是,将输入定位得足够低以与键盘顶部对齐会导致无调整大小错误.这可以通过构建离子磨砂玻璃演示和更改页脚来复制

    <footer class="bar bar-footer bar-frosted"><button class="button button-clear button-positive" ng-click="add()">Add Message</button></footer>

    <footer class="bar bar-footer bar-frosted"><input name="testInput"></footer>

    在www/index.html中

这会复制iOS7.1中的错误,并在iOS 7.0.x中按预期工作.我已经按照这里的建议,但他们的线程已过时,并没有最终工作.提前感谢您的任何见解!

Joe*_*ora 0

编辑:Ionic已在 beta 4 中修复了此问题,因此不需要进行这些黑客修复:) 感谢 Ionic 团队认识到该问题并修复它!

我现在要做的与上面@ajsnaps 的回答类似。我不认为它是一个好的解决方案,因为它有错误(类似于其他线程中指出的错误)。

当我弄清楚时,我会尝试用更好的东西来更新它,并且我会将其保持开放状态,以防有人提出更好的解决方案。

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

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

 //pull down the message area (scrollPane) and header (titleBar)
 //works on both 3.5" and 4" screens
 $("titleBar").css('top', '215px');
 $("scrollPane").css('top', '273px');

 },20); 

});

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

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

 //push the top back up
 $("titleBar").css('top', '0px');
 $("scrollPane").css('top', '56px');

 },20); 

});
Run Code Online (Sandbox Code Playgroud)

此外,我确保从聊天视图导航回来后重置标题。

希望这可以帮助!