react-native 中的键盘隐藏

Posted

技术标签:

【中文标题】react-native 中的键盘隐藏【英文标题】:Keyboard Hiding in react-native 【发布时间】:2017-07-29 01:53:29 【问题描述】:

我只是按照链接react-native: hide keyboard的答案

但是键盘会在几秒钟内闪烁,然后消失。有没有办法完全避免键盘。

【问题讨论】:

你试过***.com/questions/29685421/react-native-hide-keyboard/… 吗? 【参考方案1】:

This 帮助了我:

import  Keyboard  from 'react-native'

// Hide that keyboard!
Keyboard.dismiss();

【讨论】:

【参考方案2】:

正确的方法是使用 TouchableWithoutFeedback 关闭 View 并调用 Keyboard.dismiss()

import Keyboard from 'react-native'

<TouchableWithoutFeedback onPress=Keyboard.dismiss>
   <View style=styles.container>
      <TextInput keyboardType='numeric'/>
   </View>
</TouchableWithoutFeedback>

【讨论】:

以上是关于react-native 中的键盘隐藏的主要内容,如果未能解决你的问题,请参考以下文章

关闭键盘 React-Native

一键后iOS上的React Native TextInput隐藏键盘

在键盘感知滚动视图中的 textInput 后​​按下 React-Native 按钮

React-native:打开表情符号键盘

react-native 键盘遮挡输入框

react-native解决键盘自适应