ios - 使用 React native 以编程方式显示键盘

标签 ios react-native

如何使用 React Native 以编程方式为 TextInput 显示键盘?使用 ScrollView,在 TextInput 之间点击会导致键盘消失。我想使用 TextInput 的 onFocus 方法再次显示键盘。无论如何要完成这个?

最佳答案

考虑引用您的 textInput :

<TextInput ref={(ref)=>{this.myTextInput = ref}} />

当你必须再次聚焦它时使用:this.myTextInput.focus()

编辑 React16

对于 react16,使用 React.createRef 创建引用。

关于ios - 使用 React native 以编程方式显示键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38992297/

相关文章:

ios - 共享扩展以打开包含应用程序

ios - 无法接收 FCM(推送通知 iOS)

ios - AVCaptureOutput didOutputSampleBuffer 停止被调用

ios - React Native - 将数据从 native 发送到 javascript/桥接

javascript - react 原生 : borderBottomWidth not working

react-native - 在 react-native 中在哪里使用后台地理位置服务

javascript - 使用 React Native 和 Firebase 更改密码

ios - 类 "View controller"没有初始化程序

iphone - 如何解析 XML 的多个属性?

android - numberOfLines 在 React-Native 中不适用于 Android