KeyWindow NavigationController is null when modal is open after iOS 14.2 Update

Viewed 227

After iOS 14.2 update on Xamarin, the UIApplication.SharedApplication.KeyWindow.NavigationController is null when a popup message(modal) is open.

I am trying to PopToRoot, but I am not able to due to this bug, since NavigationController for the KeyWindow is null. Anyone having the same issue or know a work around for it?

This is only happening on iOS 14.2, it is working on iOS 14.1

1 Answers

I don't even have this property on my KeyWindow (iOS 14.2) and would recommend going with RootViewController, case it to the controller type you actually have as the root (most likely UINavigationViewController) and that will be your reference, based on your project architecture (on how you build you UI):

enter image description here

Better approach #1: implement a navigation service which will hold the reference to your UINavigrationController and whenever navigation is desired, you resolve the service via IoC and execute required methods.

Better approach #2: switch to Xamarin.Forms and Shell navigation where all this stuff is already handled and provided to you as navigation service.

Related