我正在使用react导航5:
我创建了MainStackScreen和AuthStackScreen
const AuthStack = createStackNavigator();
function AuthStackScreen() {
return (
<AuthStack.Navigator headerMode="none">
<AuthStack.Screen name="Main" component={Main} />
<AuthStack.Screen name="Login" component={Login} />
<AuthStack.Screen name="Registration" component={Registration} />
<AuthStack.Screen name="Home" component={DrawerNavigator} />
<AuthStack.Screen name="Notifications" component={Notifications} />
<AuthStack.Screen name="SmsValidation" component={SmsValidation} />
<AuthStack.Screen name="MoreRegistrationInfo" component={MoreRegistrationInfo} />
</AuthStack.Navigator>
);
}MainStackScreen:
const MainScreen = createStackNavigator();
function MainStackScreen({navigation}) {
return (
<MainScreen.Navigator>
<MainScreen.Screen name="Main" component={Main} />
<MainScreen.Screen name="SmsValidation" component={SmsValidation} />
<MainScreen.Screen name="MoreRegistrationInfo" component={MoreRegistrationInfo} />
</MainScreen.Navigator>
);
}我想阻止IOS在登录我的屏幕之间来回滑动操作
发布于 2020-09-23 00:06:37
您可以在如下屏幕中将gestureEnabled设置为false:
<AuthStack.Screen
name="Login"
component={Login}
options={{gestureEnabled: false}}
/>或者像这样的整个导航器:
<AuthStack.Navigator screenOptions={{gestureEnabled: false}}>
...
</AuthStack.Navigator>发布于 2020-09-22 23:23:08
您可以设置beforeRemove监听器以防止返回。React Navigation Docs
发布于 2020-09-23 19:31:49
/* -------------------------------------------------------------------------- */
/* AUTH STACK */
/* -------------------------------------------------------------------------- */
const AuthStack = createStackNavigator();
function AuthStackScreen() {
return (
<AuthStack.Navigator headerMode="none">
<AuthStack.Screen name="Main" component={Main} />
<AuthStack.Screen name="Login" component={Login} options={{gestureEnabled: false}} />
<AuthStack.Screen
name="Registration"
component={Registration}
options={{gestureEnabled: false}}
/>
<AuthStack.Screen name="Home" component={DrawerNavigator} options={{gestureEnabled: false}} />
<AuthStack.Screen
name="Notifications"
component={Notifications}
options={{gestureEnabled: false}}
/>
<AuthStack.Screen
name="SmsValidation"
component={SmsValidation}
options={{gestureEnabled: false}}
/>
<AuthStack.Screen
name="MoreRegistrationInfo"
component={MoreRegistrationInfo}
options={{gestureEnabled: false}}
/>
</AuthStack.Navigator>
);
}https://stackoverflow.com/questions/64012470
复制相似问题