Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/466.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将键盘永久安装在屏幕上_Javascript_Reactjs_React Native - Fatal编程技术网

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
  }
}