我正在寻找一种方法来在本机iOS中有条件地禁用滑动以返回手势。我正在使用react-navigation
库来控制导航。对于Android,我可以使用BackHandler做到这一点。在iOS中可以做类似的事情吗?
componentDidMount() {
BackHandler.addEventListener("hardwareBackPress", this.handleBackButton);
}
handleBackButton = () => {
if (this.props.creating) {
return true; // Disables the back button in Android
}
};
componentWillUnmount() {
BackHandler.removeEventListener(
"hardwareBackPress",
this.handleBackButton
);
}
是,有一个禁用手势的选项:
screen: ExampleView
navigationOptions: {
gesturesEnabled: false,
},
在此处查看更多详细信息:https://github.com/react-navigation/react-navigation/issues/1063