简体   繁体   English

ListView在IOS键盘后面呈现 - React Native

[英]ListView renders behind IOS keyboard - React Native

In my react-native app I've got a View that renders a TextInput and a ListView. 在我的react-native应用程序中,我有一个View,它呈现TextInput和ListView。 The ListView is populated based on what is typed in the TextInput. ListView根据TextInput中键入的内容进行填充。

<View styleComponent={styleComponent.mainContainer}>
  <TextInput
    onChangeText={this.onTyping.bind(this)}
    value={this.state.text} />
  <ListView
    dataSource={this.state.dataSource}
    renderRow={(rowData) => this._renderRow(rowData)} />
</View>

My problem is that part of the ListView is rendered behind the IOS keyboard. 我的问题是ListView的一部分是在IOS键盘后面呈现的。 Is there any way, without external libraries, to tell the ListView to render in the available space, ie not under the keyboard. 有没有任何方法,没有外部库,告诉ListView在可用空间中呈现,即不在键盘下。

You should use onBlur and onFocus event or keyboard events plugin and adjust your list style when keyboard opened. 您应该使用onBluronFocus事件或键盘事件插件,并在键盘打开时调整列表样式。 Take a look with this: how-to-auto-slide-the-window-out-from-behind-keyboard-when-textinput-has-focus . 看看这个: 如何自动滑动窗口从后面键盘 - 当textinput-have-focus时

Use react native's keyboar avoiding view KeyboardAvoidingView and Example Like 使用react native的keyboar避免查看KeyboardAvoidingViewExample Like

import {ScrollView, Text, TextInput, View, KeyboardAvoidingView} from "react-native";

and in render function nest the View and TextInput 并在渲染函数中嵌套ViewTextInput

<ScrollView style={styles.container}>
          <KeyboardAvoidingView behavior='position'>
                <View style={styles.textInputContainer}>
                  <TextInput
                    value={pin}
                    style={styles.textInput}
                    keyboardType='default'
                    returnKeyType='next'
                    onChangeText={this.handleChangePin}
                    underlineColorAndroid='transparent'
                    placeholder={I18n.t('pin')}/>
                </View>
          </KeyboardAvoidingView>
        </ScrollView>

It will take care of that 它将照顾到这一点

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM