gpt4 book ai didi

react-native - React Native 必须双击 onPress 才能工作

转载 作者:行者123 更新时间:2023-12-03 11:37:14 24 4
gpt4 key购买 nike

我正在将 React Native 与 Native Base 库一起使用。当键盘打开时,我需要一个 onPress 事件来触发 Native Base 的 ListItem(相当于 TouchableOpacity)。

我现在必须单击一次以关闭键盘,然后我才能按下 ListItem。

下面的内容标签相当于 ScrollableView:

<Content keyboardShouldPersistTaps='always' keyboardDismissMode='on-drag'>
<List>
<ListItem style={styles.inspectionsItemDivider} itemDivider>
<TextInput
autoFocus={true}
ref={(input) => { this.titleSearch = input }}
placeholder='Start typing...'
multiline={true}
onChangeText={this.setSearchText.bind(this)}
value={this.getSearchValue()}/>
</ListItem>
<View style={styles.searchContainer}>
<Text style={styles.recentText}>Recommended Descriptions</Text>
<List dataArray={this.state.searchedDescriptions}
renderRow={(description) =>
<ListItem button onPress={() => this.setInformationDescription(description)}>
<Text>{description}</Text>
</ListItem>
</List>
</View>
</List>
</Content>

最佳答案

我实际上只是想通了这一点。除了 Content 标签之外,我还添加了 keyboardShouldPersistTaps='always' Prop 到我的列表中:

<Content keyboardShouldPersistTaps='always' keyboardDismissMode='on-drag'>
<List>
<ListItem style={styles.inspectionsItemDivider} itemDivider>
<TextInput
autoFocus={true}
ref={(input) => { this.titleSearch = input }}
placeholder='Start typing...'
multiline={true}
onChangeText={this.setSearchText.bind(this)}
value={this.getSearchValue()}/>
</ListItem>
<View style={styles.searchContainer}>
<Text style={styles.recentText}>Recommended Descriptions</Text>
<List keyboardShouldPersistTaps='always' dataArray={this.state.searchedDescriptions}
renderRow={(description) =>
<ListItem button onPress={() => this.setInformationDescription(description)}>
<Text>{description}</Text>
</ListItem>
</List>
</View>
</List>
</Content>

关于react-native - React Native 必须双击 onPress 才能工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42808294/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com