Textfield在iOS7中的UI WebView中不会聚焦 [英] Textfield does not focus in UI WebView in iOS7

查看:162
本文介绍了Textfield在iOS7中的UI WebView中不会聚焦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果文本字段位于屏幕的下半部分,则不会聚焦,但如果位于上半部分,则文本字段无效。我在iOS7在模拟器以及安装的应用程序中的设备上发现这个问题。 Iam使用sencha touch& phonegap但我不认为他们是这个问题的原因,因为即使一个简单的文本字段位于屏幕高度的一半以下失败。

The textfield does not focus if it is located in the bottom half of the screen but it works if it is in the top half. I find this problem in iOS7 in the simulator as well as the device in an installed app. Iam using sencha touch & phonegap but I dont think they are the reason for the problem since even a simple textfield positioned below half the height of the screen fails.

当我点击文本字段,操作系统应该推动文本字段一点之前,键盘显示。但这不会发生,而是只显示键盘没有任何焦点或推动的屏幕。

When I tap on the textfield the OS should push the textfield a little above before the keyboard gets shown. But this does not happen instead only the keyboard is shown without any focus or pushing of the screen. How should I enable this in iOS7 so that I can fix the problem.

感谢

推荐答案

终于找到了问题的原因。如果您使用UIWebview,那么您应该将body标记的最小高度设置为设备的内部高度。例如,对于iPhone 4S为460px或对于iPhone 5为520px

Finally found the reason for the problem. If you are using UIWebview then you should set the min-height of the body tag to the inner height of the device. For example 460px for iPhone 4S or 520px for iPhone 5

内部高度=设备高度 - 状态栏高度= 460px,应该基本上是应用容器的高度。我把这块代码放在我的手机缝隙设备就绪功能&一切都像一个魅力

Inner Height = Device height - Status bar height = 460px which should basically be the height of the app container. I put this piece of code in my phone gap device ready function & everything worked like a charm

document.addEventListener("deviceready", function(){
    var body = document.getElementsByTagName('body')[0];
    body.style.minHeight=window.innerHeight + 'px';
}, false);

这篇关于Textfield在iOS7中的UI WebView中不会聚焦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆