我如何在 React Native 中使用 iOS 摇动手势? [英] How do i use the iOS shake gesture with react native?

查看:46
本文介绍了我如何在 React Native 中使用 iOS 摇动手势?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 React Native 中使用摇动手势.它目前用于调试菜单,我不知道如何覆盖它.有谁知道这是否可能?

I'd like to use the shake gesture with React Native. Its currently used for the debug menu and i'm not sure how to override it. Does anyone know if this is possible?

推荐答案

您可以禁用开发者模式,然后提供您自己的抖动处理程序.

You can disable developer mode and then provide your own shake handler.

https://github.com/facebook/react-native/issues/1054

您可以在 RCTDefines.h 或构建中更改 [of RCT_DEV] 值React lib 项目的设置,搜索预处理器宏"并将 RCT_DEV=0 添加到当前定义 DEBUG=1 的部分.

You can either change the value [of RCT_DEV] in RCTDefines.h, or in the build settings for the React lib project, search for "Preprocessor Macros" and add RCT_DEV=0 to the section where DEBUG=1 is currently defined.

我认为你必须实现一个 Obj-C 扩展来处理摇动手势;AFAIK 没有办法完全在 JavaScript 中做到这一点.您可能会发现开发菜单的代码是一个有用的指南:

I think you would then have to implement an Obj-C extension that handles the shake gesture; AFAIK there's no way to do this purely in JavaScript. You may find the code for the Dev Menu a useful guide for this:

https://github.com/facebook/react-native/blob/98263c4f8f6365a8c0c25e5f509928b89d8f1c0c/React/Base/RCTDevMenu.m

这篇关于我如何在 React Native 中使用 iOS 摇动手势?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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