我在 React Native 应用程序的 ScrollView 中有一个 WebView。 ScrollView 具有刷新控制属性,因此当我到达应用程序顶部时,我可以刷新 WebView。
问题是:我滚动 WebView 没有问题,但是每当我向上滑动到页面顶部时,无论我在页面的末尾、中间还是开头,都没有关系,始终会触发刷新控件。
当scrollY: 0且scrollY始终为0时,会触发RefreshControl,因为滚动的不是ScrollView而是WebView,所以ScrollView始终为scrollY: 0。
我已经在 WebView 和 ScrollView 上尝试了 rollEnabled 属性,但没有成功。
以下是代码现在的样子:
<View style={{flex: 1}}>
<ScrollView
contentContainerStyle={{flex: 1}}
refreshControl={
<RefreshControl
refreshing={this.state.refreshing}
onRefresh={this._onRefresh.bind(this)}
/>
}
>
<WebView
ref="webview"
source={{uri: initialUrl}}
/>
</ScrollView>
</View>
我已经删除了所有 Prop 以尝试重新开始,但我总是遇到同样的问题。在 iOS 上它工作正常,没有这个问题。
是的,我在这个母 View 中确实还有其他东西。
最佳答案
奇怪的是,我从 contentContainerStyle 中删除了样式,并且效果很好。只是想我会删除可能妨碍功能的额外内容。也许这是一个错误,但现在尽量避免使用 Flexbox 设置。
关于android - ScrollView中的WebView在向上滑动时调用refreshControl React Native Android一直,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50570920/