Using a UINavigationController
in Xamarin.iOS (targetting iOS 11/12) I'd like to detect, in the destination View Controller when I'm being navigated back to - i.e. a pop. I specifically want to exclude/detect when the destination VC is being pushed for the first time.
To be explicit, given that we've navigated from A to C, and back to B:
[A] -(push)-> [B] -(push)-> [C] -(pop)-> [B]
I'd like to detect/discriminate - in B - between the initial push from A -> B
and a subsequent pop from C -> B
.
Conceptually this is identical to the questions posed here and here and I should - apparently - be able to use a combination of isMovingToParentViewController
/ IsBeingPresented
/ View.Window
in ViewWillAppear()
but, having tried the approaches in both the linked questions (and a few other things), I'm not seeing the expected values for these properties; they're always False
, and View.Window
is always null
.
Is this a Xamarin.iOS-specific quirk, or am I missing something? If it is Xamarin-related is there a workaround? And if not does anyone have a bare-bones C# example of this detection working?
I'd prefer not to have to maintain state in the navigation controller (or delegate, or individual VCs) since the app structure could change in the future. However, a solution that made use of the nav controller or delegate to indicate the direction of navigation (pop vs push) to the destination VC - 'B', above - would be acceptable.