2017-07-19 48 views
2

我有一个FlatList它包裹在一个视图。如何启用或禁用FlatList上的滚动

<View {...this._panResponder.panHandlers}> 
<FlatList .../> 
</View> 

的视图是一个panResponder,所以如何在onPanResponderGrant触发禁用FlatList的滚动。

回答

4

documentation状态,一个FlatListScrollView的道具:

,并因此继承它的道具(以及那些滚动型)

如果您检查documentationScrollView,你会看到你需要做的就是将scrollEnabled prop设置为false来禁用滚动。您选择如何以及在何处选择这些将取决于您,因为您并未真正发布任何代码。一个简单的方法来处理这将是使用状态:

<FlatList 
    ... 
    scrollEnabled={this.state.scrollEnabled} 
/> 

// Change the state to the appropriate value in onPanResponderGrant: 
// To enable: 
this.setState({ scrollEnabled: true }) 
// To disable: 
this.setState({ scrollEnabled: false }) 
+0

我知道这个道具,但它似乎不工作,我会再试一次,谢谢你! – cityvoice

相关问题