devxoul / URLNavigator

⛵️ Elegant URL Routing for Swift
MIT License
3.25k stars 297 forks source link

Topmost does not return the right UIViewController #158

Open Bruno-Clairet opened 2 years ago

Bruno-Clairet commented 2 years ago

If the app uses a AVPictureInPictureController, the topmost method does not return the right UIViewController. When the video starts playing the AVPictureInPictureController creates two extra UIWindow.

var rootViewController: UIViewController? let currentWindows = UIApplication.shared.windows

for window in currentWindows {
  if let windowRootViewController = window.rootViewController {
    rootViewController = windowRootViewController
    break
  }
}

The first UIWindow is not the key window, it is created by the Picture in Picture View Controller.