如何在反应本机导航器中禁用向后滑动手势 [英] How to disable back swipe gesture in react native navigator

查看:50
本文介绍了如何在反应本机导航器中禁用向后滑动手势的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 React Native 开发一个 iOS 应用程序.我使用了 React Native 的 Navigator 组件.当我将用户从一个屏幕推送到另一个屏幕时,用户可以通过在屏幕左边缘滑动来弹出屏幕.我知道如何在本机 iOS 代码中禁用它.但是,我们有什么方法可以阻止 React 原生应用中的这种行为.

I am developing one iOS application in react native. I have used Navigator component of react native. When I am pushing user from one screen to another then user can able to pop the screen by swipe on the left edge of the screen. I know how to disable it in native iOS code. However is there any way we can Stop that behavior in React-native app.

谢谢,

推荐答案

我按照下面的方式解决了,

I solved it below way,

在 React 项目中,我有 node_modules 文件夹.这个路径有导航组件的代码,

In React Project I have node_modules folder. There is code for Navigator component at this path,

/node_modules/react-native/Libraries/CustomComponents/Navigator/Navigator.js

/node_modules/react-native/Libraries/CustomComponents/Navigator/Navigator.js

在该文件中,有针对导航手势的操作.通过从那里移除弹出"手势,当从屏幕左边缘滑入时会停止弹出.

In that file There is actions for Gestures on Navigations. By removing 'pop' gesture from there stops poping back when slide in from left edge of the screen.

只需替换下面的代码,

var GESTURE_ACTIONS = [
  'pop',
  'jumpBack',
  'jumpForward',
];

使用此代码,

var GESTURE_ACTIONS = [
  'jumpBack',
  'jumpForward',
];

这篇关于如何在反应本机导航器中禁用向后滑动手势的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆