简体   繁体   English

Xamrin.Forms Navigation.PopAsync不更改Android上的页面

[英]Xamrin.Forms Navigation.PopAsync not changing page on android

I have a login button, which when clicked triggers this method: 我有一个登录按钮,单击该按钮会触发此方法:

async void OnLoginButtonClicked(object sender, EventArgs e)
    {
        Navigation.InsertPageBefore(new SiteSelectionPage(), this);
        await Navigation.PopAsync();
    }

On iOS it works fine and the new page and title appear. 在iOS上运行正常,并显示新页面和标题。 On Android the title of the page changes from "Login" to "Site Selection" (which is what I want), but the content does not change at all (the username and password Entry boxes are still on the page). 在Android上,页面标题从“登录”更改为“站点选择”(这是我想要的),但是内容根本没有更改(用户名和密码输入框仍在页面上)。

Does anyone know why this is happening specifically on Android? 有谁知道为什么这是专门在Android上发生的?

I can see in your code that you are trying to login the user, so what you can try is changing the App.MainPage in stead of doing that: 我可以在您的代码中看到您正在尝试登录用户,因此可以尝试更改App.MainPage而不是这样做:

Application.Current.MainPage = new NavigationPage(new SiteSelectionPage());

Then if you want to remember if the user is already logged in you can try storing a Setting with this NuGet Package: 然后,如果您想记住用户是否已经登录,可以尝试使用此NuGet软件包存储设置:

https://www.nuget.org/packages/Xam.Plugins.Settings/ https://www.nuget.org/packages/Xam.Plugins.Settings/

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

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