React Native ScrollView 有时不会滚动到底部

编程入门 行业动态 更新时间:2024-10-13 14:21:18
本文介绍了React Native ScrollView 有时不会滚动到底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在我的应用程序 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 有时不会滚动到底部

本文发布于:2023-10-11 14:23:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1481958.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:React   Native   ScrollView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!