iOS 键盘会顶起导航栏,隐藏键盘底部布局不还原

iOS 键盘会顶起导航栏,隐藏键盘底部布局不还原
图片描述
图片描述
图片描述

经过恨多次不同的尝试,还是一样的问题,附上所有的页面代码,烦请帮忙看看,谢谢了

<template>
    <!--<navpage style="display: flex;flex-direction: column"
            dataRole="none"
            :height="navBarHeight"
            backgroundColor="#1296DB"
            leftItemSrc="http://onnqn1z06.bkt.clouddn.com/image/close.png"
            :title="title"
            titleColor="white"
            @naviBarLeftItemClick="naviBarLeftItemClick">-->
        <list style="height: 999;flex:1;overflow: auto;-webkit-overflow-scrolling: touch">
            <cell>
                <div style="border-bottom-width: 2;border-bottom-color: #F5F5F5;padding-bottom: 30">
                    <div style="margin-top:20;margin-right:10;margin-left:10;flex-direction: row;justify-content: center;align-items: center;" @click="userIndex(comment.userId)">
                        <div style="flex: 1;flex-direction: row;align-items: center;" >
                            <image style="height: 80;width: 80;border-radius: 50;" :src="comment.avatar" :placeholder="placeholderImg"></image>
                            <text style="margin-left: 10;color: #333333;font-size: 30">{{comment.nickname}}</text>
                        </div>
                        <div style="flex: 2;align-items: flex-end;margin-right: 40">
                            <div v-if="subscribehide" @click="follow" item="ture" :style="{backgroundColor:subscribe==0?'#1296DB':'',borderWidth:(subscribe=='1'?'1':'0'),borderColor:subscribe==1?'#d5d5d5':''}" style="border-radius: 50;width: 100;height: 45;justify-content: center;align-items: center;">
                                <text :style="{color:subscribe==0?'white':'#c3c3c3'}"  style="font-size:24">{{subscribe==0?'关注':'已关注'}}</text>
                            </div>
                        </div>
                    </div>
                    <div class="content" style="margin-left: 90;margin-right: 15;font-size: 25">
                        <text style="color: #454434;font-size: 28">{{comment.content}}</text>
                        <text style="color: rgb(20,20,20);font-size: 25;margin-top: 10">{{comment.createDateText}}</text>
                    </div>
                </div>
            </cell>
            <cell>
                <div>
                    <text style="color: #c8c8c8;font-size: 30;margin-left: 20;margin-top: 20">全部评论</text>
                </div>
            </cell>
            <cell v-for="(commItem,index) in commentReplyList">
                <div style="margin-left: 10;margin-right: 10;margin-top: 20">
                <div style="flex-direction: row;justify-content: center;align-items: center;">
                        <div style="flex: 1; flex-direction: row;align-items: center" @click="userIndex(commItem.userId)">
                            <image style="height: 60;width: 60;border-radius: 50;" :src="commItem.avatar" :placeholder="placeholderImg"></image>
                            <text style="color: #406599;margin-left: 10;font-size: 26">{{commItem.nickname}}</text>
                        </div>
                        <div style="flex: 2;align-items: flex-end;margin-right: 30;">
                            <div style="flex-direction: row;align-items: center;" @click="zanEvaer" :item="commItem">
                                <image v-if="commItem.isLike==1" src="http://onnqn1z06.bkt.clouddn.com/image/yzan.png" style="width: 30;height: 30"></image>
                                <image v-if="commItem.isLike==0" src="http://onnqn1z06.bkt.clouddn.com/image/zan2.png" style="width: 30;height: 30"></image>
                                <text style="color: #aaaaaa;font-size: 25">{{commItem.likecount}}</text>
                            </div>
                        </div>
                    </div>
                    <div style="margin-left: 70;">
                        <text style="color: rgb(20,20,20);font-size: 24">{{commItem.content}}</text>
                        <div style="flex-direction: row;align-items: center;margin-top: 10;">
                            <text style="color: rgb(20,20,20);font-size: 20;">{{commItem.createDateText}}·</text>
                            <text v-if="commItem.commentcount>0" style="color: rgb(20,20,20);font-size: 20;border-radius: 30;padding-left: 10;height: 35;text-align: center;line-height: 35; padding-right: 10;background-color: #F7F5F6">{{commItem.commentcount}}回复</text>
                            <text v-else style="color: rgb(20,20,20);font-size: 20;text-align: center;">回复</text>
                        </div>
                    </div>
                </div>
            </cell>
        </list>
        <div style="bottom: 0;background-color: #FFFFFF;height: 88;align-items:center;flex-direction: row">
            <div >
                <input placeholder="请输入" :value="sendcomment" return-key-type="send" @return = "onreturn" @input="onincommentInput" ref="commentInput" type="text" style="background-color:#FAFAFA;width:575;border-width:1;border-color:#EEEEEE;border-radius: 10; height: 60;font-size: 24;padding-left: 10"/>
            </div>
        </div>
    <!--</navpage>-->
</template>
<script>
    module.exports = {
        data: {
            domHeight:0,
        },
        created: function() {
            this.domHeight = weex.config.env.deviceHeight / weex.config.env.deviceWidth*750 - (88*2+50);
            
        }
    }
</script>
阅读 4.8k
4 个回答

ios fixed在可视界面高度宽度发生变化时会出现异常,比如软键盘弹起收起。建议使用flex布局,在使用flex兼容性写法的情况下,flex基本可以兼容市面的手机了。使用flex不会出现布局异常的情况。

@佘贞标
您好!感谢你的解答,我尝试使用flex布局,结果还是一样。我附上了我的页面结构,请指点一下谢谢了。

<template>
<div>
    <!--长列表 -->
    <list>
    ...
    </list>
    
    <!--底部评论菜单 -->
    <div style="flex: 1;bottom: 0;background-color: #FFFFFF;height: 88;align-items:center;flex-direction: row">
            <div style="flex: 4;">
                <input placeholder="请输入" :value="sendcomment" return-key-type="send" @return = "onreturn" @input="onincommentInput" ref="commentInput" type="text" style="background-color:#FAFAFA;width:575;border-width:1;border-color:#EEEEEE;border-radius: 10; height: 60;font-size: 24;padding-left: 10"/>
            </div>
            <div style="flex: 1">
                <div style="background-color: #0088fb;border-radius: 10; width: 110;height:60;justify-content: center">
                    <text style="color: white;text-align: center;font-size: 24" @click="send">发送</text>
                </div>
            </div>
    </div>
</div>
</template>

是weex的SDK源码的问题,手动改一下吧

./platforms/ios/Pods/WeexSDK/ios/sdk/WeexSDK/Sources/Component/WXEditComponent.m

文件路径根据自己的项目找一下,找到WXEditComponent.m里的blur方法

文件路径根据自己的项目找一下,找到WXEditComponent.m里的blur方法,然后添加一行

[[NSNotificationCenter defaultCenter] postNotificationName:UIKeyboardWillHideNotification object:nil];

在失去焦点的时候重置一下位置就好了

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进