TouchableHighlight inside Viewpager在本机ios中以点击方式记录页面更改事件
我们在应用程序中使用了TouchableHighlight inside Viewpager在本机ios中以点击方式记录页面更改事件,ios,react-native,touchablehighlight,Ios,React Native,Touchablehighlight,我们在应用程序中使用了查看页面(react native community/react native viewpager),每个页面有3个部分,所有3个部分都是可点击的,为了使其可点击,我们使用了TouchableHighlight 因此,每当我通过滑动来更改页面时。如果我在IOS中的TouchableHighlight中使用滑动触控功能,它就如同在android中单击其他功能一样,工作正常。为像我这样的其他用户提供帮助 这个库的开发者的回答 嘿, 您可以使用onPageScrollState
查看页面
(react native community/react native viewpager
),每个页面有3个部分,所有3个部分都是可点击的,为了使其可点击,我们使用了TouchableHighlight
因此,每当我通过滑动来更改页面时。如果我在
IOS
中的TouchableHighlight
中使用滑动触控功能,它就如同在android
中单击其他功能一样,工作正常。为像我这样的其他用户提供帮助
这个库的开发者的回答
嘿,
您可以使用onPageScrollStateChanged方法阻止按钮交互。
switch(pageScrollState){
case "idle": enableButton();
default: disableButton();
}
或者我用过这种方法
this.state = {
shouldEnableClick: true,
};
pageScroll = (event) => {
draggingValue = event.nativeEvent.offset
isNotStill = (draggingValue == 0 || draggingValue == 1) ? true : false
{Platform.OS == 'ios' && this.changeValue(isNotStill)}
}
changeValue(isNotStill) {
if (this.state.shouldEnableClick !== isNotStill) {
this.setState({ shouldEnableClick: isNotStill })
}
}
在组件中,我像这样使用它
let enableCLick = this.state.shouldEnableClick
let clickAction = () => this.myAction()
<TouchableHighlight
onPress={enableCLick && clickAction}/>
let enableCLick=this.state.shouldEnableClick
让我们单击Action=()=>this.myAction()