ScrollView/KeyboardAwareScrollView 无法正常工作
我有以下代码:
<SafeAreaView style={styles.container}>
<StatusBar />
<KeyboardAwareScrollView keyboardShouldPersistTaps='handled' contentContainerStyle={styles.keyboardAwareScrollView}>
<ScrollView ref={scrollViewRef} onContentSizeChange={() => scrollViewRef.current.scrollToEnd({ animated: true })} keyboardShouldPersistTaps='handled'>
{steps.map(item => { return (<SingleAlgorithmStep key={item["Question"]} step={item} stepsDone={steps} clickedButtons={clickedButtons} algorithmJson={currentAlgorithmJson} actualizeSteps={(item) => updateSteps(item)} actualizeButtons={(item) => updateClickedButton(item)} />) })}
</ScrollView>
</KeyboardAwareScrollView>
</SafeAreaView>
具有这些样式:
container: {
flex: 1,
flexDirection: 'column',
backgroundColor: '#fff',
alignItems: 'center',
padding: 10
},
keyboardAwareScrollView: {
flex: 1
},
有时 SingleAlgorithmStep
仅包含按钮,有时包含文本输入。如果在 Android 上运行该应用程序,一切正常。但是当我在 ios 上运行它并且收到文本输入时,滚动视图不会完全向下滚动。我必须关闭键盘并重新打开它才能手动向下滚动。我该如何解决这个问题?
I'm having the following code:
<SafeAreaView style={styles.container}>
<StatusBar />
<KeyboardAwareScrollView keyboardShouldPersistTaps='handled' contentContainerStyle={styles.keyboardAwareScrollView}>
<ScrollView ref={scrollViewRef} onContentSizeChange={() => scrollViewRef.current.scrollToEnd({ animated: true })} keyboardShouldPersistTaps='handled'>
{steps.map(item => { return (<SingleAlgorithmStep key={item["Question"]} step={item} stepsDone={steps} clickedButtons={clickedButtons} algorithmJson={currentAlgorithmJson} actualizeSteps={(item) => updateSteps(item)} actualizeButtons={(item) => updateClickedButton(item)} />) })}
</ScrollView>
</KeyboardAwareScrollView>
</SafeAreaView>
with these styles:
container: {
flex: 1,
flexDirection: 'column',
backgroundColor: '#fff',
alignItems: 'center',
padding: 10
},
keyboardAwareScrollView: {
flex: 1
},
Sometimes the SingleAlgorithmStep
contains just buttons sometimes it contains a textinput. If runnig the app on android, everything works fine. But when i'm running it on ios and i get a text input, the scrollview does not scrolling completly down. I have to close the keyboard and reopen it oder manually scroll down. How can I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论