弹出层中多个输入框,iOS微信下点击错位问题

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/xiaomajia029/article/details/95166866

问题描述

iOS微信下,弹出层中有多个输入框时,点击获取焦点后,元素位置错位;同时收起键盘后不能再次输入;相关按钮无法点击。

PS. 这是微信在iOS下的bug

解决办法

在输入框 blur 的时候调用 window.scrollTo

具体操作如下:

html

 <input type="number" v-model="phone" @blur="scrollto0">

js

methods:{
    setTimeout(()={
        // 调起键盘前滚动条为0, 直接执行 window.scrollTo(0, 0);
        // 调起键盘前滚动条不为0,需自行处理滚动条位置,具体如下:
        const scrollT = document.documentElement.scrollTop || document.body.scrollTop || 0;
        window.scrollTo(0, Math.max(scrollT -1, 0))
    }, 200)
}
展开阅读全文

IOS多个UIView添加点击

11-22

刚刚接触IOS开发,遇到以下问题想不通,希望高手给予指导。我给sendView、 payVIew、receiverView、 commentView设置点击事件,为什么n UITapGestureRecognizer * singleRecognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(viewClick:)];n singleRecognizer.numberOfTapsRequired = 1;n [self.sendView addGestureRecognizer:singleRecognizer]; n [self.payVIew addGestureRecognizer:singleRecognizer];n [self.receiverView addGestureRecognizer:singleRecognizer];n [self.commentView addGestureRecognizer:singleRecognizer];n 只有commentView能够响应点击事件,其他的三个UIView都无法响应点击事件,但是我要是改成nn UITapGestureRecognizer * singleRecognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(viewClick:)];n singleRecognizer.numberOfTapsRequired = 1;n [self.sendView addGestureRecognizer:singleRecognizer];n n UITapGestureRecognizer * singleRecognizer1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(viewClick:)];n singleRecognizer1.numberOfTapsRequired = 1;n [self.payVIew addGestureRecognizer:singleRecognizer1];n n UITapGestureRecognizer * singleRecognizer2 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(viewClick:)];n singleRecognizer2.numberOfTapsRequired = 1;n [self.receiverView addGestureRecognizer:singleRecognizer2];n n UITapGestureRecognizer * singleRecognizer3 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(viewClick:)];n singleRecognizer3.numberOfTapsRequired = 1;n [self.commentView addGestureRecognizer:singleRecognizer3];n 就可以了呢?希望好心人能够给我这个新手指点迷津 问答

没有更多推荐了,返回首页