listView中的触摸可访问需要2个点击onpress



我有一个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属性

相关内容

  • 没有找到相关文章

最新更新