1

我正在使我的应用程序在带有iOS 13的iPadOS上使用多个窗口,据我所知,由于它已被弃用,我无法直接访问窗口,我怎样才能获得最顶层的视图控制器?UIApplication

iOS12之前我使用这个工作解决方案,你能建议一个替代方案吗?

+(UIViewController *)topMostViewController
{
    UIViewController *vc = [[UIApplication sharedApplication].delegate.window rootViewController];
    while(vc.presentedViewController)
    {
        vc = vc.presentedViewController;
    }
    return vc;
}
4

1 回答 1

-2

请参阅:如何获取多窗口 SceneDelegate Xcode 11 的当前 keywindow 等效项?

已弃用: 您尝试过Application.shared.keyWindow?.rootViewController吗?keyWindow (或者如果你喜欢)是这里的重要部分mainWindow

于 2019-08-15T09:40:46.480 回答