【问题标题】:Navigation Issue while navigating using Android Hardware Back Press [react-native]使用 Android 硬件 Back Press [react-native] 导航时出现导航问题
【发布时间】:2017-11-09 06:54:13
【问题描述】:

当我使用硬件后按从我的应用程序的最终屏幕导航到第一个屏幕时
它最初会导航到第一个屏幕并弹回最终屏幕

此外,我在第一个屏幕中给出的动画在导航时变成了卡住和播放体验,这两种导航类型的情况都是一样的,即,

-使用应用程序中的后退按钮导航,同时使用硬件后退按钮

这是我处理硬件后按的最终屏幕 js 文件:

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

  componentDidMount() {
    BackHandler.addEventListener('hardwareBackPress', this.handleBack);
  }

  componentWillUnmount() {
   BackHandler.removeEventListener('hardwareBackPress', this.handleBack);
 }

这是我有动画的第一个屏幕的 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();
         }

【问题讨论】:

    标签: javascript react-native


    【解决方案1】:

    在您的final screen js file 中添加:

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

    【讨论】:

      猜你喜欢
      • 2020-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多