iOS上的React-Native scrollToEnd与手动滚动的行为不同,将项目置于底部(React-Native scrollToEnd on iOS behaves differently than scrolling manually, putting items to bottom)

请在iOS上考虑此示例: https : //sketch.expo.io/SyeyMSx_il

尝试手动滚动,一切看起来都很正常: 没有评论消息保持在最顶层。

如果您现在单击此按钮则无评论消息将粘贴到底部。

如果再次手动滚动,一切都恢复正常。

为什么使用scrollToEnd应该与手动滚动不同? 以及如何解决这种奇怪的行为?

Please consider this example on iOS: https://sketch.expo.io/SyeyMSx_il

Try to scroll manually, everything looks normal: No comments message stays on top.

If you click now on the button now, the No comments message sticks to the bottom.

If you scroll manually again, everything goes normal again.

Why using scrollToEnd should be different than scrolling manually? And how to fix this weird behaviour?

最满意答案

添加到ScrollView contentContainerStyle={{ flexGrow: 1 }}修复了该问题。 现在看: https : //snack.expo.io/HkdP9_e1Z

Adding to ScrollView contentContainerStyle={{ flexGrow: 1 }} fixed that. See now: https://snack.expo.io/HkdP9_e1Z

更多推荐