![](/img/trans.png)
[英]Swipe transition to go back works, but pressing the back button does not go back
[英]Prevent user from swipe back or using physical back button to go back to splash screen
我无法阻止用户返回启动画面。 以前当我使用 React Navigation 4 时,这是我使用的
const resetAction = StackActions.reset({
index: 0,
actions: [NavigationActions.navigate({ routeName: "HomeScreen" })]
});
navigation.dispatch(resetAction);
但在 React Navigation 5 中,我尝试了以下代码但没有成功:
const resetAction = CommonActions.reset({
index: 0,
actions: [CommonActions.navigate({ name: screenName })]
});
navigation.dispatch(resetAction);
或这个:
navigation.reset({
index: 0,
routes: [{ name: "HomeScreen" }]
});
我还尝试在Stack.Screen
options
道具或Stack.Navigator
screenOptions
道具中将gestureEnabled
设置为 false,但我仍然可以向右滑动到 go 回到初始屏幕。
有没有人有任何解决方法? 谢谢你。
网站上有一个身份验证流程指南,可能有用:这里。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.