React Native Touchable组件onPress方法在使用PanResponder时失效,iphone6,iphone 6S

收到测试反馈iphone6和iPhone6s上点击列表有时无法跳转到详情页面,调试时候发现点击touchable组件时,有时会执行onPress方法,有时会执行PanResponder的方法

手指点击屏幕面积比较小时执行onPress,否则会执行PanResponder方法

可能是因为点击屏幕面积比较大时,系统认为进行了移动操作,所以进入了PanResponder方法,解决方法就是在响应PanResponder的时候判断,只有移动超过多少像素才去响应Move

	onMoveShouldSetPanResponder: (evt, gestureState) => {
		let {dx,dy} = gestureState;
		if((Math.abs(dx) > 5) || (Math.abs(dy) > 5)){
			return true
		}else{
			return false
		}
        //return  (Math.abs(dx) > 5) || (Math.abs(dy) > 5); 不使用这种写法,某些三星机器异常
    }

猜你喜欢

转载自blog.csdn.net/w20101310/article/details/83348056