2017-04-05 55 views

回答

0

我认为你不应该记住所有的导航堆栈。您的设备决定关闭应用程序,或者从后台出现的最后一页重新启动。我认为如果你是“登录”,你可以记住:如果你是“登录”,你可以从第一页重新启动,“登录后”,否则从登录“开始”。

对于这种情况,你可以去看一下this link和使用Properties

public class App : Xamarin.Forms.Application 
{ 
    public App() 
    { 
    } 

    protected override void OnStart() 
    { 
     // Handle when your app starts 
     Debug.WriteLine ("OnStart"); 
     checkLogin(); 

    } 

    protected override void OnSleep() 
    { 
     // Handle when your app sleeps 
     Debug.WriteLine ("OnSleep"); 
    } 

    protected override void OnResume() 
    { 
     // Handle when your app resumes 
     Debug.WriteLine ("OnResume"); 
     checkLogin(); 
    } 
} 

void checkLogin(){ 

     if (Application.Current.Properties.ContainsKey("IsLogged")) 
     { 
      var IsLogged = Application.Current.Properties ["IsLogged"] as bool; 
      // do something with IsLogged 
      if(IsLogged) 
       MainPage = new MyFirstPage(); 
      else 
       MainPage = new MyLoginPage(); 
     } 
     else 
      MainPage = new MyLoginPage(); 
} 

那么,当你在

Application.Current.Properties ["IsLogged"] = true; 
+0

我要澄清已经登录 - 这基本上是我的逻辑分钟。如果他们已登录,请将它们带到一个页面,如果不是,请将它们带到另一个页面。但是,在iOS中,如果用户启动了控制中心,它会暂停应用程序,当他们退出控制中心时,它会执行我不想要的“简历”逻辑。 –