ios - RefreshControl 仅出现在水平 ScrollView (iOS)中的第一个子项之上

标签 ios uiscrollview react-native pull-to-refresh uirefreshcontrol

我有一个用例,我想水平列出卡片。 我用水平 ScrollView 实现了它.

然后,我想为每张卡片实现下拉刷新模式,以便更新卡片中显示的数据。 因此我使用了 RefreshControl组件作为 ScrollView 的一个属性。

问题是,在 iOS 上,当我切换到第一张卡以外的另一张卡时,我看不到 RefreshControl 组件(请参见下面的 gif)。

horizontal scroll with refresh control iOS

代码

<ScrollView
  contentContainerStyle={styles.container}
  horizontal
  pagingEnabled
  showsHorizontalScrollIndicator={false}
  directionalLockEnabled
  contentInset={{top: 1}}
  refreshControl={
    <RefreshControl
      refreshing={this.state.isRefreshing}
      onRefresh={this._onRefresh.bind(this)}
    />
  }
>
  <Text style={styles.card}>First child</Text>
  <Text style={styles.card}>Second child</Text>
</ScrollView>

下面演示中的完整代码

演示 https://rnplay.org/apps/sRXpEw

编辑

它看起来与这部分代码相关:Libraries/Components/ScrollView/ScrollView.js#L523-L529

最佳答案

据我所知,这是 refreshControl 的预期行为 - 应该只有一个。

这对您的应用有用吗?

<ScrollView
  contentContainerStyle={styles.container}
  horizontal
  pagingEnabled
  showsHorizontalScrollIndicator={false}
  directionalLockEnabled
  contentInset={{top: 1}}
>
  <ScrollView
    refreshControl={
      <RefreshControl
        refreshing={this.state.isRefreshing}
        onRefresh={this._onRefresh.bind(this)}
      />
    }><Text style={styles.card}>First child</Text></ScrollView>
  <ScrollView
    refreshControl={
      <RefreshControl
        refreshing={this.state.isRefreshing}
        onRefresh={this._onRefresh.bind(this)}
      />
    }><Text style={styles.card}>Second child</Text></ScrollView>
</ScrollView>

关于ios - RefreshControl 仅出现在水平 ScrollView (iOS)中的第一个子项之上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40493187/

相关文章:

ios - 每个 TableViewCell 的 IBAction 不返回唯一的 NSIndexPath

ios - 如何在 Swift 中从 LPLinkMetadata 获取图像 URL

iphone - 3 UIScrollview 上的 UIWebView 在浏览时崩溃

uitableview - setScrollsToTop 与多个 UIScrollView 类和/或子类 (UITableView)

xcode - React-native 设置用于构建/存档的 ENVFILE 文件

ios - 将新委托(delegate)添加到新 Controller 的问题

IOS Firebase 按值查询访问

swift - 如何检测 UITableView 标题何时滚动?

javascript - 使用 React Native 将一个数组拆分为两个数组

react-native - POST 失败,ReadableNativeMap 无法转换为字符串错误