Reputation: 325
On App class I have this :
MainPage = new NavigationPage(new MainPage());
In MainPage OnAppearing :
protected async override void OnAppearing ()
{
base.OnAppearing ();
if (TempUserInfo.IsNewUser ())
await this.Navigation.PushModalAsync ( new SignUpPage ());
}
On SignUpPage after user enters all information , I use this :
await this.Navigation.PushModalAsync (new VerificationCodePage());
Finally , after I check verification code on VerificationPage I used this:
await this.Navigation.PopToRootAsync ();
Now , I'm getting this error :
PopToRootAsync is not supported globally on iOS, please use a NavigationPage.
What I want to achieve is exactly like this navigation setup above .
Upvotes: 3
Views: 3816
Reputation: 2372
This solution worked as i expected on Android. Put these in App.xaml.cs
public static MyMasterDetail RootPage()
{
return (MyMasterDetail)Current.MainPage;
}
public static void NavigateToHomePage()
{
try
{
MainPage homePage = new MainPage();
MyMasterDetail masterDetailRootPage = (MyMasterDetail)Application.Current.MainPage;
masterDetailRootPage.Detail = new NavigationPage(homePage);
masterDetailRootPage.IsPresented = false;
Current.MainPage = masterDetailRootPage;
}
catch (Exception ex)
{
Debug.WriteLine("!!! NavigateToHomePage() Exception !!!");
Debug.WriteLine("Exception Description: " + ex);
}
}
Then you could call from anywhere to go home
App.NavigateToHomePage();
Or show masterdetail left side menu
App.RootPage().IsPresented = true;
Upvotes: 0
Reputation: 325
I resigned navigation to what Jason suggested and in the VerificationPage , I used this :
MainPage = new NavigationPage(new MainPage());
Thanks everyone for your help .
Upvotes: 1
Reputation: 9521
Instead of doing
await this.Navigation.PopToRootAsync ();
You can reset the main page :
MainPage = new NavigationPage(new MainPage());
Upvotes: 1