14

In Xamarin.Forms, when we use Navigation.PopAsync(), the page does not pop in iOS.

After PopAsync() the same page remains.

Brandon Minnick
  • 13,342
  • 15
  • 65
  • 123
Chetan Rawat
  • 174
  • 1
  • 3
  • 10
  • 2
    Can you show some code, please? – Sven-Michael Stübe Jan 21 '17 at 12:46
  • Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. See: [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). – ashley Jan 21 '17 at 14:45

1 Answers1

31

Call the Proper Pop Method

If you pushed the page onto the Navigation Stack using Navigation.PushAsync(), use Navigation.PopAsync() to pop the page off of the Navigation Stack.

If you pushed the page on to the Navigation Stack using Navigation.PushModalAsync(), use Navigation.PopModalAsync() to pop the page off of the Navigation Stack.

Use BeginInvokeOnMainThread

All UI updates must be done on the main thread. To ensure that this request is happening on the main thread, use BeginInvokeOnMainThread:

Device.BeginInvokeOnMainThread(async () => await Navigation.PopAsync());

or

Device.BeginInvokeOnMainThread(async () => await Navigation.PopModalAsync());
Brandon Minnick
  • 13,342
  • 15
  • 65
  • 123
  • 1
    Thanks for the help :) – Chetan Rawat Jan 24 '17 at 08:30
  • Disappointed that this is needed. It suggests that the concrete implementation is using 2 stacks which allows for the possibility of the wrong page being displayed. Windows sometimes opens forms 'behind' the application. Has anyone ever seen the same problem Xamarin? – Paul McCarthy Oct 23 '19 at 15:32