Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
256 views
in Technique[技术] by (71.8m points)

How do i use the iOS shake gesture with 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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

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.

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...