【发布时间】:2019-10-22 11:45:39
【问题描述】:
我正在寻找一种方法来有条件地禁用滑动返回手势以响应原生 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
);
}
【问题讨论】:
-
你试过我的答案了吗?
标签: ios react-native react-navigation