NativeScript Angular 2 在 ios 上禁用回扫 [英] NativeScript Angular 2 disable swipe back on ios

查看:20
本文介绍了NativeScript Angular 2 在 ios 上禁用回扫的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何在导航到新页面后禁用向后滑动吗?

does anyone know how to disable the back swipe after navigating to a new page?

我读过这个:http://docs.nativescript.org/angular/core-concepts/angular-navigation#clearing-page-navigation-history

清除页面导航历史在 NativeScript 的页面导航中,您可以选择导航到另一个页面并清除该页面导航历史.这意味着用户将无法前往使用后退按钮返回(或在 iOS 中向后滑动).这在在您有登录页面但不希望用户进入的情况下登录后可以返回.但我想在用户点击退出时返回登录页面.

Clearing Page Navigation History In NativeScript's page navigation, you have the option to navigate to another page and clear the page navigation history. This means that the user will not be able to go back using the back button (or swipe back in iOS). This is useful in scenarios where you have a login page and you don't want users to be able go go back to it once logged in. But I want to go back to login page when the user clicked logout.

我有 2 个页面,LoginPage 和 FirstPage.我正在使用 RouterExtensions.所以 this.nav.navigate([/firstPage"], { clearHistory: true});这有效.在第二页上,我有一个按钮可以转到 this.nav.navigate([/"]) (因此返回登录页面).但我明白了

I have 2 pages, LoginPage and FirstPage. Im using RouterExtensions. so this.nav.navigate(["/firstPage"], { clearHistory: true}); this works. On second page i have a button that goes to this.nav.navigate(["/"]) (so back to the login page). But I get

8 月 11 日 19:30:26 antons-MBP appname[62814]:控制台错误file:///app/tns_modules/zone.js/dist/zone-node.js:421:23: 错误:Uncaught (in promise): TypeError: undefined is not an object(评估'cacheItem.reusedRoute')

Aug 11 19:30:26 antons-MBP appname[62814]: CONSOLE ERROR file:///app/tns_modules/zone.js/dist/zone-node.js:421:23: Error: Uncaught (in promise): TypeError: undefined is not an object (evaluating 'cacheItem.reusedRoute')

推荐答案

我能够通过插入以下代码来禁用每页滑动手势

I was able to disable the swipe gesture per page by inserting the following code

constructor(private nav: RouterExtensions) {

    this.nav.frame.ios.controller.interactivePopGestureRecognizer.enabled = false;

  }

这种方式我不必修改库,但缺点是我必须在我想要向后滑动以处理的每个页面上重新启用interactivePopGestureRecognizer".

This way I don't have to modify the library, but the downside is that I have to re-enable "interactivePopGestureRecognizer" on every page that i want to the back swipe to work on.

这篇关于NativeScript Angular 2 在 ios 上禁用回扫的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆