我有一个TextInput,它将呈现一个ListView提示文本以自动完成,但是TouchableOpacity需要2次点击才能触发(首先关闭键盘)
将keyboardShouldPersistTaps="always"
添加到ListView
不能不能解决问题。
代码:
render() {
const { selected, searched } = this.state;
return (
<View>
<TextInput
onChangeText={this.searchedText}
underlineColorAndroid="transparent"
onBlur={this.blurInput}
/>
<ListView
keyboardShouldPersistTaps="handled"
style={styles.autoCompleteListView}
dataSource={ds.cloneWithRows(searched)}
renderRow={this.renderRow.bind(this)}
/>
</View>
);
}
...
renderRow = (rowData) => (
<TouchableOpacity
onPress={this._onPressRow.bind(this, rowData)}
>
<Text>{ rowData }</Text>
</TouchableOpacity>
);
答案 0 :(得分:2)
https://github.com/facebook/react-native/issues/10138#issuecomment-304344283
所有嵌套组件都需要keyboardShouldPersistTaps
属性