我有一个textInput,它将渲染listView提示文本以自动完成,但是TouchableOpacity需要触发2个单击(首先要解散键盘)
将 keyboardShouldPersistTaps="always"
添加到 ListView
do 不解决问题。
代码:
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>
);
https://github.com/facebook/react-native/issues/10138#issuecomment-304344283
所有嵌套组件都需要keyboardShouldPersistTaps
属性