在微信中iOS点击输入框、选择框,点击软键盘上的完成后,底部依然有空白,这就导致了触摸点发生错位,错位的偏移位置大概就是底部留白的部分,在网上搜了其它一些资料后,自己写了这段代码到项目里,管用!不过还是希望微信能早日解决这个问题吧,毕竟看到最初反馈这个问题是在2018年年底的时候了。。
tips:input元素iOS中没有写type类型时是没法输入和获取焦点的
var iOSPagescrollTimer = null;
$("body").on("focus","select,input[type=text],input[type=number]",function(){
var agent = navigator.userAgent.toLocaleLowerCase();
if(agent.indexOf("micromessenger") != -1 && agent.indexOf("iphone") != -1 && !$(this).attr("readonly")){
clearTimeout(iOSPagescrollTimer);
}
})
$("body").on("blur","select,input[type=text],input[type=number]",function(){
var agent = navigator.userAgent.toLocaleLowerCase();
if(agent.indexOf("micromessenger") != -1 && agent.indexOf("iphone") != -1 && !$(this).attr("readonly")){
iOSPagescrollTimer = setTimeout(function(){
$(window).scrollTop($(window).scrollTop()+2)
},500);
}
})