Skip to content

Topmost does not return the right UIViewController #158

Description

@Bruno-Clairet

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions