本机基础需要键盘内容

时间:2018-06-15 07:59:27

标签: react-native native-base

例如,有一个页脚,我希望键盘隐藏它。现在我有这样的事情:

enter image description here

enter image description here

我需要做什么?

PS:我使用的是native-base。

1 个答案:

答案 0 :(得分:1)

  

至少你必须尝试使用​​一些代码! - 见How To Ask

任何方式,你必须import { Keyboard } from "react-native";并添加监听器。只要键盘打开,就隐藏页脚。

类似的东西:

  componentDidMount () {
    this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', this._keyboardDidShow);
    this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this._keyboardDidHide);
  }

  componentWillUnmount () {
    this.keyboardDidShowListener.remove();
    this.keyboardDidHideListener.remove();
  }

  _keyboardDidShow () {
    // change the state of showFooter to false
  }

  _keyboardDidHide () {
    // change the state of showFooter to true
  }

查看Keyboard Docs