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;
}
see: How get current keywindow equivalent for multi window SceneDelegate Xcode 11?
deprecated:
Have you triedApplication.shared.keyWindow?.rootViewController
? The keyWindow (ormainWindow
if you like) is the important part here.