2

I am working on a project where initial screens are in SwiftUI and further flow is in UIKit controllers. My problem is I want to know the visibleController on the screen or UINavigationController of the navigation stack when any of the appDelegate functions (let's say open:URL, performActionFor:shortcutItem) gets triggered.

So for that I tried to use UIApplication.shared.windows.filter {$0.isKeyWindow}.first.rootViewController but it is giving me as something like this <_TtGC7SwiftUI19UIHostingControllerGVS_15>. So here I m not getting the UINavigationController or the current visibleController.

So any idea on how to get the UINavigationController or the visible UIViewController or the NavigationStack.

Thanks in advance!

Hyder
  • 139
  • 1
  • 10
  • The `rootViewController` you've got is an instance of `UIHostingController`, which is a subclass of `UIViewController`, so you can use it as usually to present another controller, access navigationController, etc. – Asperi Mar 31 '20 at 03:51
  • 2
    @Asperi When we try to access ```navigationController``` it is nil. – Hyder Mar 31 '20 at 05:05

0 Answers0