当我按下返回按钮(从堆栈标题)或从左向右滑动时,ios 应用程序崩溃



当我在物理iPhone设备中按返回按钮(在堆栈标题中(或从左向右滑动时,我的反应本机应用程序崩溃了。该应用程序在模拟器中工作正常,但在物理设备中无法正常工作。

那么,我该如何解决此问题?

这是我的主导航器的代码

import { themeColor, themeColorLite } from "../styles/common";
import Login from "../views/Login"
import ForgetPass from "../views/forgetPass"
import Registration from "../views/Registration"
import UserDashboard from "../views/user/dashboard"
import ProductDetails from "../views/user/productDetails"
import ShoppingMall from "../views/user/shoppingMalls"
import Shops from "../views/user/shops"
import NormalProducts from "../views/user/normalProducts"
import ShoppingCart from "../views/user/shoppingCart"
import UserProfile from "../views/user/profile"
import { createSwitchNavigator, createAppContainer } from 'react-navigation'
import { createStackNavigator } from 'react-navigation-stack'
import { createDrawerNavigator } from 'react-navigation-drawer'
import UserDrawerNav from '../views/drawerNav'
const ProductStackNavigator = createStackNavigator({
UserDashboard: UserDashboard,
ProductDetails: ProductDetails,
ShoppingCart: ShoppingCart,
ShoppingMall: ShoppingMall,
Shops: Shops,
NormalProducts: NormalProducts
})
const DrawerNavigator = createDrawerNavigator(
{
UserDashboard: ProductStackNavigator,
ShoppingMall: ProductStackNavigator,
UserProfile: UserProfile
},
{
contentComponent: UserDrawerNav,
hideStatusBar: true,
drawerBackgroundColor: 'white',
overlayColor: themeColorLite,
contentOptions: {
activeTintColor: '#fff',
activeBackgroundColor: themeColor,
}
}, {
unmountInactiveRoutes: true
}
);
const AuthStack = createSwitchNavigator({ 
Login: { screen: Login } ,
Registration: { screen: Registration } ,
ForgetPass: { screen: ForgetPass }
});
const AppContainer = createAppContainer(createSwitchNavigator(
{
App: DrawerNavigator,
Auth: AuthStack
},
{
initialRouteName: 'Auth',
}
));
export default AppContainer;

这是我的包.json

{
"name": "ENC",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"ipadAir": "react-native run-ios --simulator 'iPad Air (3rd generation)'",
"start": "react-native start",
"iphone11": "react-native run-ios --simulator 'iPhone 11'",
"cleanStart": "react-native start --reset-cache",
"link": "react-native link",
"podInstall": "cd ios && pod install && cd ..",
"podUpdate": "cd ios && pod update && cd ..",
"upgradeRN": "react-native upgrade",
"regenDir": "react-native upgrade --legacy true",
"test": "jest"
},
"dependencies": {
"@react-native-community/async-storage": "^1.6.1",
"axios": "^0.19.0",
"react": "16.10.1",
"react-native": "0.61.2",
"react-native-flip-card": "^3.5.5",
"react-native-fs": "^2.14.1",
"react-native-gesture-handler": "^1.4.1",
"react-native-image-picker": "^1.1.0",
"react-native-photo-upload": "^1.3.0",
"react-native-really-awesome-button": "^1.4.2",
"react-native-reanimated": "^1.2.0",
"react-native-tiny-toast": "^1.0.3",
"react-native-webview": "^7.4.0",
"react-native-xml2js": "^1.0.3",
"react-navigation": "^4.0.5",
"react-navigation-drawer": "^2.2.1",
"react-navigation-stack": "1.5.1"
},
"devDependencies": {
"@babel/core": "^7.5.0",
"@babel/runtime": "^7.5.0",
"@react-native-community/eslint-config": "^0.0.5",
"babel-jest": "^24.1.0",
"jest": "^24.1.0",
"metro-react-native-babel-preset": "^0.56.0",
"react-test-renderer": "16.10.1"
},
"jest": {
"preset": "react-native"
}
}

上面的代码也可以在我的要点中找到 这里

在 xcode 中分析问题后终于找到了解决方案 这个解决方案对我很好: https://github.com/kmagiera/react-native-gesture-handler/issues/320#issuecomment-447534290

最新更新