在我的应用程序 index.io.js 中,只有 1 个 ScrollView 被包裹在 render 函数下的 View 中.有时我可以滚动到 ScrollView 的最底部并将屏幕保持在那里.但是 ScrollView 有时会弹回到屏幕顶部而无法停留在底部.
inside my application index.io.js there is only 1 ScrollView that is wrapped inside a View under the render function. Sometimes I can scroll to the very bottom of the ScrollView and keep the screen there. However the ScrollView would bounce back to the top of the screen and fail to stay at the bottom sometimes.
有谁知道发生了什么?谢谢.
Does anyone know what is happening? Thanks.
render() { return <View style={{flex: 1}}> <ScrollView> <Text>234</Text> <Text>234</Text> <Text>234</Text> <Text>234</Text> // .... repeat so many times ... </ScrollView> </View> }ps:我的RN是0.28.0,iOS部署目标是8.0
p.s: my RN is 0.28.0, iOS deployment target is 8.0
推荐答案对于像我这样的 React Native 新手:
For React native newbies like me:
注意在滚动视图的 contentContainerStyle 属性上设置 {flex:1} 的错误,这基本上是明确告诉滚动视图不要滚动并期望它滚动,因为这将内容高度设置为与滚动视图相同的父框架
lookout for making the error of setting {flex:1} on the scrollview's contentContainerStyle attribute, which is basically telling the scrollview explicitly not to scroll and expecting it to scroll, since this sets the content height to the same parent's frame which is the scrollview
更多推荐
React Native ScrollView 有时不会滚动到底部
发布评论