1

I'm conforming my application to use multiple windows on iPadOS with iOS 13, as far as I know I cannot access to UIApplication window directly due to it's deprecation, how can I get the top most view controller?

Until iOS12 I use this working solutions, can you suggest an alternative?

+(UIViewController *)topMostViewController
{
    UIViewController *vc = [[UIApplication sharedApplication].delegate.window rootViewController];
    while(vc.presentedViewController)
    {
        vc = vc.presentedViewController;
    }
    return vc;
}
Kathiresan Murugan
  • 2,114
  • 2
  • 19
  • 35
Fabiosoft
  • 883
  • 12
  • 23
  • Does this answer your question? [How get current keywindow equivalent for multi window SceneDelegate Xcode 11?](https://stackoverflow.com/questions/57009283/how-get-current-keywindow-equivalent-for-multi-window-scenedelegate-xcode-11) – Carsten Feb 05 '20 at 11:25
  • not fully, as i keep learning it's always better to user `view.window` – Fabiosoft Feb 05 '20 at 11:28

1 Answers1

-2

see: How get current keywindow equivalent for multi window SceneDelegate Xcode 11?

deprecated: Have you tried Application.shared.keyWindow?.rootViewController? The keyWindow (or mainWindow if you like) is the important part here.

Carsten
  • 986
  • 13
  • 25