OnPanresponderRelease不用在Android设备上工作



当我在iOS设备上使用panresponders时,它可以正常工作,但是在我在Android设备上运行时,代码无法正常工作。代码如下

componentWillMount() {
    this._panResponder = PanResponder.create({
        onStartShouldSetPanResponder: (evt, gestureState) => true,
        onStartShouldSetPanResponderCapture: (evt, gestureState) => true,
        onMoveShouldSetPanResponder: (evt, gestureState) => true,
        onMoveShouldSetPanResponderCapture: (evt, gestureState) => true,
        onPanResponderGrant: (evt, gestureState) => {
            return true;
        },
        onPanResponderTerminationRequest: (evt, gestureState) => {
            console.log('getting on android');
            return false;
        },
        onPanResponderRelease: (evt, gestureState) => {
            console.log('getting here')
            return true;
        },
        onPanResponderTerminate : (evt, gestureState) => {
            console.log('gets');
        }
    });
}

我的scrollview片段也如下。

<ScrollView
      ref={ref => this.myScroll = ref }
      {...this._panResponder.panHandlers}>

使其正常使用onPanResponderEnd而不是onPanResponderRelease

另外,如果我们仍然要使用onPanResponderRelease,则应通过以下方式允许终止请求:

onPanResponderTerminationRequest: () => true

相关内容

  • 没有找到相关文章

最新更新