zoukankan      html  css  js  c++  java
  • react-native 键盘遮挡输入框

    Android上已经自动对键盘遮挡输入框做了处理,所以我们只需要关注ios。

    1.首先引入 KeyboardAvoidingView

    import { KeyboardAvoidingView } from 'react-native';
    

    2.然后在页面的最外层加上 KeyboardAvoidingView

    render(){
        return <KeyboardAvoidingView behavior={'padding'} style={{flex: 1}}>
            {/*具体页面内容*/}
        </KeyboardAvoidingView>
    }
    

    如果适配ios和Android,可以将页面提取出来

        getPageView = () => {
            //return 具体页面内容
        }
        getPlatformView = () => {
            if (Platform.OS === 'ios') {
                return <KeyboardAvoidingView behavior={'padding'} style={{flex: 1}}>
                        {this.getPageView()}
                </KeyboardAvoidingView>
            } else {
                return this.getPageView();
            }
        };
    
        render() {
            return this.getPlatformView();
        }
    
  • 相关阅读:
    su 命令切换用户带来的问题
    系统无法启动
    Linux单用户模式
    反射
    propety/静态方法
    内置方法,序列化模块
    第1月5周3天
    第1月4周5天
    第1月4周4日
    第1月4周3日
  • 原文地址:https://www.cnblogs.com/bygw/p/11327141.html
Copyright © 2011-2022 走看看