【问题标题】:WebView in ScrollView calling refreshControl when swiping up React Native Android all the timeScrollView中的WebView在一直向上滑动React Native Android时调用refreshControl
【发布时间】:2018-05-28 17:11:10
【问题描述】:

我在 React Native 应用程序的 ScrollView 中有一个 WebView。 ScrollView 具有 refreshControl 属性,因此当我到达应用程序顶部时可以刷新 WebView。

问题是:我滚动 WebView 没有问题,但是每当我向上滑动到页面顶部时,无论我是在页面的末尾、中间还是开头,都没有关系, refreshControl 总是被触发。

当scrollY:0且scrollY一直为0时触发RefreshControl,因为滚动的不是ScrollView而是WebView,所以ScrollView一直在scrollY:0。

我已经在 WebView 和 ScrollView 上尝试了 scrollEnabled 属性,但都没有成功。

下面是代码现在的样子:

<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>

我已经删除了所有的道具来尝试重新开始,但我总是遇到同样的问题。在 iOS 上它工作正常,没有这个问题。

是的,我在这个母亲视图中确实有其他东西。

【问题讨论】:

    标签: android react-native webview scrollview pull-to-refresh


    【解决方案1】:

    奇怪的是,我从 contentContainerStyle 中删除了样式,并且效果很好。只是想我会删除可能阻碍该功能的额外内容。也许这是一个错误,但现在尽量避免在其中使用 Flexbox 设置。

    【讨论】:

    • 遇到同样的问题 - 没有contentContainerStyle,webview 是不可见的,并且在 webView 上具有固定高度,不幸的是仍然调用刷新。 RN 0.63.1react-native-webview ^10.3.2
    猜你喜欢
    • 1970-01-01
    • 2017-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-23
    • 1970-01-01
    相关资源
    最近更新 更多