react-native-keyboard-aware-scroll-view无法正常工作

我正在尝试使用react-native-keyboard-aware-scroll-view,因此键盘不会覆盖我的输入。

出于某种原因,它总是认为键盘处于活动状态,我猜是因为它总能压缩所有内容。

随附的是正在发生的事情以及代码。 任何人都有任何想法在这里发生什么事吗? 我已经玩了一段时间并没有运气。 我正在运行react-native v 0.33和react-native-keyboard-aware-scroll-view v 0.2.1。

https://www.npmjs.com/package/react-native-keyboard-aware-scroll-view

在此处输入图像描述

import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'; class LoginIOS extends Component{ constructor(props) { super(props); this.login = this.login.bind(this); this.renderScene = this.renderScene.bind(this); this.state={ username: '', password: '' }; } render() { return ( <Navigator renderScene={this.renderScene} navigator={this.props.navigator} navigationBar={  } /> ); } renderScene() { return (                this.setState({username: text})} value={this.state.username} >        this.setState({password: text})} value={this.state.password} onSubmitEditing={(event)=> { this.login(); }} >         Sign In    ); } 

我通过使用另一个lib解决了这个问题。 不确定为什么react-native-keyboard-aware-scroll-view不起作用,但是如果你实现react-native-keyboard-aware-view,你应该没有任何问题。

https://www.npmjs.com/package/react-native-keyboard-aware-view

您还可以使用动画视图作为滚动视图,不能具有绝对视图或固定组件。 所以听取键盘事件并使调整工作正常。

 onKeyboarDidShow(e) { //LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut) Animated.timing(this.relativeBottom, { duration: e.duration, toValue: Dimensions.get('window').height-em(64)-e.endCoordinates.height }).start() } onKeyboardWillHide(e) { //LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut) Animated.timing(this.relativeBottom, { duration: e.duration, toValue: Dimensions.get('window').height-em(64) }).start() } componentWillMount() { this._didShowListener = Keyboard.addListener('keyboardWillShow', this.onKeyboarDidShow.bind(this)); this._willHideListener = Keyboard.addListener('keyboardWillHide', this.onKeyboardWillHide.bind(this)); } componentWillUnmount() { this._didShowListener.remove(); this._willHideListener.remove(); } 

个人用flex解决了这个问题…