相关疑难解决方法(0)

React Native必须双击onPress才能工作

我正在使用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>
Run Code Online (Sandbox Code Playgroud)

react-native native-base

21
推荐指数
2
解决办法
8374
查看次数

React Native TextInput blur消耗TouchableHighlight按事件

<TextInput>当我点击红色的Post按钮时,我有一个我要提交的内容<TouchableHighlight>.当TextInput聚焦时,我完成输入并点击Post按钮,键盘关闭但按钮没有注册水龙头.

我尝试使用TextInput onBlur事件,但它没有给我触摸点的坐标,所以我不知道触摸点是否实际上是在按钮上.

截图

ios react-native

19
推荐指数
2
解决办法
3495
查看次数

在React Native中,可以在键盘打开时调用onPress

用户需要在点击两次FlatList项目,因为autoFocus={true}<TextInput。第一次单击时,键盘处于隐藏状态,然后单击呼叫onPress={this.GetItem.bind(this, item)}。是否可以选择GetItem()单击一次而不是单击两次。

演示:https//snack.expo.io/ByJ_yWehM

export default class App extends Component {
  GetItem (item) {
    console.log(item);
    Alert.alert(item);
  }
  render() {
    return (
      <View style={styles.container}>
        <TextInput
          autoFocus={true}
          style={styles.paragraph}
          keyboardType='web-search'
        >
          Change code in the editor and watch it change on your phone!
          Save to get a shareable url.
        </TextInput>
        <Card title="Local Modules">
          <View>
            <TextInput
              style={styles.searchField}
              placeholder="Type here to translate!"
              onChangeText={(text) => this.setState({text})}
            />

            <FlatList
                data={["akin","alike","close","comparable","like","similar","uniform","Allied","Analogous","Co-ordinate","Commensurate","akin","alike","close","comparable","like","similar","uniform","Allied","Analogous","Co-ordinate","Commensurate"]}
                renderItem={({item}) => (
                  <Text
                    style={styles.listField} …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-native react-native-ios react-native-flatlist

0
推荐指数
1
解决办法
994
查看次数