잘 작동하지 않는 Xamarin.Forms를 사용하여 이상한 동작이 발생합니다.Xamarin.Forms 탭 페이지 및 로그 아웃
앱의 기본 흐름은 방문 페이지가 로그인 양식이라는 것입니다. 로그인하면 탭이있는 페이지로 이동합니다. 로그 아웃 기능을 사용하면 로그인 페이지로 돌아 오지만 탭은 그대로 유지됩니다. Login.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="TechsportiseApp.Login">
<ContentPage.Padding>
<OnPlatform x:TypeArguments="Thickness"
iOS="20, 40, 20, 20"
Android="20, 20, 20, 20"
WinPhone="20, 20, 20, 20" />
</ContentPage.Padding>
<ContentPage.Content>
<StackLayout VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand"
Orientation="Vertical"
Spacing="15">
<Label Text="Email" />
<Entry x:Name="email" Text="[email protected]" />
<Label Text="Password" />
<Entry x:Name="password" Text="xxxxxx" IsPassword="true"/>
<Button x:Name="loginButton" Text="Login" Clicked="OnLogin"/>
<Button x:Name="registerButton" Text="Register Account" Clicked="OnRegister"/>
<Button x:Name="clearButton" Text="Reset" Clicked="OnClear"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>
내가 로그인에 대한 API에서 성공 코드를 얻을 경우
은이 절에서는 MainPage로 이동합니다.
Login.xaml.cs
//Valid response
if (response.StatusCode.ToString() == "OK")
{
Application.Current.Properties["Token"] = tokenobject.access_token;
string token = Application.Current.Properties["Token"].ToString();
Navigation.InsertPageBefore (new MainPage(), this);
await Navigation.PopAsync();
}
에서 MainPage.xaml은 다음과 같습니다과 탭 탐색 페이지입니다.
<?xml version="1.0" encoding="UTF-8"?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:TechsportiseApp.MainUI"
x:Class="TechsportiseApp.MainUI.MainPage">
<local:Races />
<local:Timer />
<local:Scanning />
<NavigationPage Title="Settings">
<x:Arguments>
<local:Settings />
</x:Arguments>
</NavigationPage>
</TabbedPage>
각 페이지가 모두 유효합니다. 설정 페이지에는 로그 아웃 버튼이 있습니다. 이
async void OnLogout(object sender, EventArgs e)
{
Application.Current.Properties["Token"] = "";
Navigation.InsertPageBefore (new Login(), this);
await Navigation.PopAsync();
}
그러나 최종 결과를하고
Settings.xaml.cs에서 로그 아웃 버튼으로
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="TechsportiseApp.MainUI.Settings"
Title="Settings">
<ContentPage.Content>
<StackLayout>
<Label Text="Settings will go here" HorizontalOptions="Center" VerticalOptions="CenterAndExpand" />
<Button x:Name="logoutButton" Text="Logout" Clicked="OnLogout" VerticalOptions="CenterAndExpand" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
Settings.xaml 내가 로그인 화면을 가지고있다 .. . 하단의 탭 막대와 함께
내가 잘못 했나요? 로그 아웃 할 때 탭이 보이지 않도록하고 싶습니다. 새로운 MainPage 설정
감사합니다, 매트
NavigationPage는 TabbedPage 내부에 있으므로 탐색으로 수행하는 모든 작업은 TabbedPage 내에 유지됩니다. 대신 앱의 MainPage를 바꿔야합니다. – Jason
NavigationPage 내에서 TabbedPage를 움직여보십시오. 로그 아웃 할 때 로그인 페이지로 이동하십시오. –