0
votes

I have a strange problem.I used latest of Xamarin.forms(v 3.1.0.583944). On iOS, I need to navigate from one page to another page. so I used following code:

NavigationPage Root;

public void SetRootView(NavigationPage root)
    {

        try
        {
            App.Instance.MainPage = root;
            Root = root;
        }
        catch (System.Exception ex)
        {
             // handle exception
        }
    }

in another method(generic) i declare that has code to push to navigation stack:

public async Task PushViewAsync<TView>() where TView : Page             
 {             
     var view = GetView<TView>();                     
      await Root.PushAsync(view);             
 }

but it does not push it to another page. There are no error or exception. But it just stay there. However if i tap on the screen, it goes to next page.

This is absolutely working fine on android. So not sure what it cause on iOS. Any thoughts?

1

1 Answers

0
votes

You need to be on the UI thread when navigating.

Device.BeginInvokeOnMainThread (async() => {
  await Root.PushAsync(view);
});