Javascript 将键盘永久安装在屏幕上
是否可以使键盘在屏幕上始终可见 屏幕上有:Javascript 将键盘永久安装在屏幕上,javascript,reactjs,react-native,Javascript,Reactjs,React Native,是否可以使键盘在屏幕上始终可见 屏幕上有: 一个TextInput(多行) 两个FlatList 当我在TextInput中键入内容时,它是正常的,但当我将内容更改为平面列表时,键盘被隐藏 无论我在屏幕上做什么,我都希望键盘始终可见 我测试的是: keyboardPersistTaps='always'键盘不工作 开始时,我将autoFocus设置为TextInput,每次键盘被隐藏时都会再次显示。我认为我可以这样做,使过渡不可见,但它不工作,因为它应该是 有什么方法可以做到这一点吗?您
- 一个
(多行)TextInput
- 两个
FlatList
TextInput
中键入内容时,它是正常的,但当我将内容更改为平面列表时,键盘被隐藏
无论我在屏幕上做什么,我都希望键盘始终可见
我测试的是:
键盘不工作keyboardPersistTaps='always'
- 开始时,我将
设置为autoFocus
,每次键盘被隐藏时都会再次显示。我认为我可以这样做,使过渡不可见,但它不工作,因为它应该是TextInput
有什么方法可以做到这一点吗?您应该在
键盘上添加一个事件监听器。当触发事件时,它将隐藏名称输入并聚焦文本字段
大概是这样的:
import React, { Component } from "react";
import { Keyboard, TextInput } from "react-native";
class MyComponent extends Component {
componentDidMount() {
this.keyboardWillHideListener = Keyboard.addListener(
"keyboardWillHide",
this._keyboardWillHide,
);
}
componentWillUnmount() {
this.keyboardWillHideListener.remove();
}
_keyboardWillHide() {
// Focus the input
}
render() {
// Your UI here
}
}
更多信息可在此处找到:不起作用。效果不变
import React, { Component } from "react";
import { Keyboard, TextInput } from "react-native";
class MyComponent extends Component {
componentDidMount() {
this.keyboardWillHideListener = Keyboard.addListener(
"keyboardWillHide",
this._keyboardWillHide,
);
}
componentWillUnmount() {
this.keyboardWillHideListener.remove();
}
_keyboardWillHide() {
// Focus the input
}
render() {
// Your UI here
}
}