繁体   English   中英

无法从内容页面执行 PopAsync、PopModalAsync 和 PopToRootAsync

[英]Not able to do PopAsync, PopModalAsync and PopToRootAsync from the content page

我正在使用代码从一个页面导航到另一个页面

await Application.Current.MainPage.Navigation.PushModalAsync(new IntercomRecieveCallPage()); 

从 IntercomRecieveCallPage 我使用以下代码导航到 IntercomCallPage

await Application.Current.MainPage.Navigation.PushModalAsync(new IntercomCallPage());

从 IntercomCallPage 我正在尝试使用以下代码进行后退导航

await App.Current.MainPage.Navigation.PopModalAsync();

但我收到以下异常

指数超出范围。 必须是非负数且小于集合的大小。 参数名称:索引

我还尝试了 PopAsync,即以下代码

await App.Current.MainPage.Navigation.PopAsync(true);

为此,我也得到了同样的例外。 我尝试使用以下代码清除导航堆栈

Navigation.RemovePage(rootPage);

但它仍然没有帮助。 我不知道如何解决这个问题。 有什么建议么?

根据 Modals page popping上的文档,只需拥有 .PopModalAsync( ) 就足够了。

就像评论一样,我认为它不会有太大变化,但也许要确保您从同一个命名空间(app.Current 与 Application.Current)调用这两种方法。

但是,在我这边进行测试时,push 和 pop 似乎都可以正常工作(即使使用应用程序或应用程序)。

但是,作为下一步,我建议您使用与 IntercomCallPage 不同的页面来测试您的用例。 只是为了排除此页面包含会导致加载/重新加载而不是导航调用错误的列表的可能性。

在推第二个之前尝试弹出第一个:

await Application.Current.MainPage.Navigation.PopModalAsync();
await Application.Current.MainPage.Navigation.PushModalAsync(new IntercomCallPage());

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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