简体   繁体   中英

Ionic 4 Disable iOS Swipe Back in ONE PAGE ONLY

I want to disable iOS in one page only and not globally, so let's say a user checkouts and makes the payment, i don't want the user to go back to where he was after he gets the receipt. I want the user to stay to that page without the possibility to swipe back, in android i have already disabled the hardware button while in iOS i am struggling a bit.

i have added to app.module:

IonicModule.forRoot({ swipeBackEnabled: false })

which disables the swipe back globally and thats what i don't want, i also tried this one:

Article about disabling swipe back

I followed it and still i could not reach what i want,

I also don't get what the user says at the end:

The current implementation only works with a single IonRouterInstance in the application but it can be enhanced with support for additional instances if you require that in your own application.

What does he mean by WORKS WITH A SINGLE?

Thank you very much, any help would be appreciated.

Inject IonRouterOutlet into your class:

constructor(private routerOutlet: IonRouterOutlet) {}

Deactivate swipe gesture where you want (typically in ngOnInit or ionViewDidEnter ):

ngOnInit() {
    this.routerOutlet.swipeGesture = false;
}

Activate it again when you need it (typically in ionViewWillLeave or ionViewDidLeave ):

ionViewWillLeave() {
    this.routerOutlet.swipeGesture = true;
}

Did it help you? Help me back with an upvote.

答案可以在离子论坛这里找到

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM