【发布时间】:2020-12-29 15:23:20
【问题描述】:
我正在使用堆栈导航,我想使用滑动返回。但是,即使我一直向右滑动屏幕,应用程序也不会导航到上一个屏幕并且屏幕会向后滑动。
import { View } from 'react-native';
import Main from './components/Main'
import Options from './components/Options'
import 'react-native-gesture-handler';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
const Stack = createStackNavigator();
export default function App() {
return (
<NavigationContainer>
<View>
<Stack.Navigator initialRouteName="Main" screenOptions={{ gestureResponseDistance: {horizontal: 20}}}>
<Stack.Screen name="MainScreen" component={Main} options={{ headerShown: false }}/>
<Stack.Screen name="OptionsScreen" component={Options} options={{ headerShown: false }}/>
</Stack.Navigator>
</View>
</NavigationContainer>
);
}
需要明确的是,我可以滑动屏幕,但是一旦我松开手指,屏幕就会滑回其初始位置,无论我滑动多快,我都无法触发滑动返回。
【问题讨论】:
-
为什么你用 view 包裹你的堆栈导航器?是否有任何特殊要求,因为使用视图包装堆栈导航器可能会产生问题。如果没有特殊要求用视图包装你的堆栈导航器,那么删除
并重试。 -
删除
并不能解决问题。它仍然具有相同的行为。
标签: ios reactjs react-native expo react-navigation