NativeScript Angular 2禁用在iOS上向后滑动 [英] NativeScript Angular 2 disable swipe back on ios

查看:139
本文介绍了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应用程序名称[62814]:控制台错误 文件:///app/tns_modules/zone.js/dist/zone-node.js:421:23:错误: 未捕获(承诺):TypeError:undefined不是对象 (评估"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天全站免登陆