[英]React Native: ListView renders before dataSource being set
[英]ListView renders behind IOS keyboard - React Native
在我的react-native應用程序中,我有一個View,它呈現TextInput和ListView。 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>
我的問題是ListView的一部分是在IOS鍵盤后面呈現的。 有沒有任何方法,沒有外部庫,告訴ListView在可用空間中呈現,即不在鍵盤下。
您應該使用onBlur
和onFocus
事件或鍵盤事件插件,並在鍵盤打開時調整列表樣式。 看看這個: 如何自動滑動窗口從后面鍵盤 - 當textinput-have-focus時 。
使用react native的keyboar避免查看KeyboardAvoidingView和Example Like
import {ScrollView, Text, TextInput, View, KeyboardAvoidingView} from "react-native";
並在渲染函數中嵌套View
和TextInput
<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>
它將照顧到這一點
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.