gpt4 book ai didi

javascript - 使用 Android 硬件后退键导航时出现导航问题 [react-native]

转载 作者:行者123 更新时间:2023-12-03 03:05:13 25 4
gpt4 key购买 nike

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

此外,我在第一个屏幕中给出的动画在导航时变得卡住并播放类似的体验,这种情况对于两种类型的导航都是相同的,即,

-使用应用程序中的后退按钮进行导航,也可以在使用硬件后按时进行导航

这是我处理硬件后按的最终屏幕 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();
}

最佳答案

在您的最终屏幕 js 文件中添加以下内容:

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

关于javascript - 使用 Android 硬件后退键导航时出现导航问题 [react-native],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47195667/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com