0
ログインユーザーとログアウトユーザーに問題があります。すべてが良い動作しますが、ログアウトは初めてで、私はボタンのログインおよびクリックした後をクリックした場合、私は再びアプリを起動した場合、私は唯一の空白のページを持っていると私は最初のケースに似XamarinフォームのユーザーログインとログアウトがAndroidで機能しない
App.csコードを作品thahtアプリをアンインストールする必要があります。
public App()
{
InitializeComponent();
if (!Current.Properties.ContainsKey("IsLoggedIn"))
{
Current.Properties["IsLoggedIn"] = false;
if ((bool)Current.Properties["IsLoggedIn"] == false)
{
MainPage = new LoginPage();
}
else
{
MainPage = new NavigationPage(new MainPage());
}
}
}
ログインページ:
async private void Button_Clicked_Login(object sender, EventArgs e)
{
Application.Current.Properties["IsLoggedIn"] = true;
await Application.Current.SavePropertiesAsync();
Application.Current.MainPage = new NavigationPage(new MainPage());
}
がログアウト:
async private void Button_Clicked(object sender, EventArgs e)
{
Application.Current.Properties["IsLoggedIn"] = false;
await Application.Current.SavePropertiesAsync();
Application.Current.MainPage = new LoginPage();
}