我有一个用例,我想水平列出卡片。 我用水平 ScrollView 实现了它.
然后,我想为每张卡片实现下拉刷新模式,以便更新卡片中显示的数据。 因此我使用了 RefreshControl组件作为 ScrollView 的一个属性。
问题是,在 iOS 上,当我切换到第一张卡以外的另一张卡时,我看不到 RefreshControl 组件(请参见下面的 gif)。
代码
<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/