React-Native-nouth-wight键盘间隔者如何使用Ontoggle



我正在使用React-Native-keyboard-间隔器。我想实现自动弹出键盘的功能。文档说onToggle method is called when when keyboard toggles. Two parameters passed through, keyboardState (boolean, true if keyboard shown) and keyboardSpace (height occupied by keyboard)谁能向我展示如何完成此操作的示例?

ontoggle()仅在之后称为。为了实现您想要的功能,只需在组件完成安装时使用TextInput中的内置方法来焦点输入:

componentDidMount() {
    this._myTextInput.focus();
}
render() {
    return (
      <TextInput
        style={{height: 40}}
        ref={component => this._myTextInput = component}
        />
    );
}

onToggle get get nath the键盘显示或隐藏。如果您想在没有用户单击任何内容的情况下弹出键盘,则需要在TextInput上进行focus()

handleOnToggle(keyboardState, keyboardSpace) {
    // Do whatever you want with keyboardState
}
render() {
    return <View>
        <KeyboardSpacer onToggle={this.handleOnToggle} />
    </View>
}

相关内容

  • 没有找到相关文章

最新更新