简体   繁体   English

使用Android硬件导航时出现导航问题Back Press [react-native]

[英]Navigation Issue while navigating using Android Hardware Back Press [react-native]

When I navigate to the first screen from the final screen of my App using hardware back press 当我使用硬件后退键从应用程序的最终屏幕导航到第一个屏幕时
It initially navigates to first screen and also bounces back to the final screen 最初会导航到第一个屏幕,然后反弹回最后一个屏幕

Also the animation that I have given in the first screen becomes a stuck and play like experience while navigating and this case is same for both types of navigation ie., 另外,我在第一个屏幕中给出的动画在导航时会变得停滞不前,像玩游戏一样 ,这种情况对于两种类型的导航都是相同的,即

-navigating with the back button in App and also while using hardware back press -在App中使用后退按钮进行导航,以及在使用硬件后按时

This is my final screen js file where I handle hardware back press: 这是我最后的屏幕js文件,我在其中处理硬件后按:

 constructor(props) { super(props); this.handleBack = (() => { Actions.FirstScreen(); }); } componentDidMount() { BackHandler.addEventListener('hardwareBackPress', this.handleBack); } componentWillUnmount() { BackHandler.removeEventListener('hardwareBackPress', this.handleBack); } 

and this is the first screen's js file where I have the animation: 这是动画的第一个屏幕的js文件:

  componentWillMount() { this.slide1 = new Animated.Value(0); this.slide2 = new Animated.Value(0); this.bnt1(); this.bnt2(); } bnt1() { Animated.timing( this.slide1, { delay: 100, toValue: w / 1.33, duration: 700, } ).start(); } bnt2() { Animated.timing( this.slide2, { delay: 700, toValue: -(w / 1.33), duration: 500, } ).start(); } 

In your final screen js file add this: 在您final screen js file添加以下内容:

 constructor(props) { super(props); this.handleBack = (() => { Actions.FirstScreen(); return true; }); } 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何阻止Android硬件后退按钮在react-native的react-navigation中运行? - How to stop the Android Hardware Back Button from functioning in react-navigation for react-native? React-Native BackHandler始终在Android中关闭App(硬件返回) - React-Native BackHandler always closes App in Android (hardware back) 当双击按钮快速反应时阻止导航 - Prevent navigating when double press button quickly react-native React-Native 与 Expo:手柄硬件返回按钮 - React-Native with Expo: Handle Hardware Back Button 向后导航时的本机重新运行功能 - react-native re-run function on navigating back 使用纯JavaScript将React-Native(Expo)应用发送到Android后退按钮按下的背景吗? - Send a React-Native (Expo) app to the background on Android back button press with pure JavaScript? 在React-Native中使用按钮按下从抽屉导航屏幕到抽屉导航屏幕的方法是什么? - What is the way to go from Drawer Navigation Screen to a Screen out of Drawer navigation using button press in React-Native? 如何在 React-navigation/react-native 中隐藏后退按钮 - how to hide back button in React-navigation/react-native 使用 React-Native Navigation 传递数据 - Passing Data Using React-Native Navigation React-native 导航可以拦截后面的动作吗? - React-native navigation is it possible to intercept the back action?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM