uiwindow - iOS13中具有多个窗口场景的最顶级视图控制器
问题描述
我正在使我的应用程序在带有iOS 13的iPadOS上使用多个窗口,据我所知,由于它已被弃用,我无法直接访问窗口,我怎样才能获得最顶层的视图控制器?UIApplication
在iOS12之前我使用这个工作解决方案,你能建议一个替代方案吗?
+(UIViewController *)topMostViewController
{
UIViewController *vc = [[UIApplication sharedApplication].delegate.window rootViewController];
while(vc.presentedViewController)
{
vc = vc.presentedViewController;
}
return vc;
}
解决方案
请参阅:如何获取多窗口 SceneDelegate Xcode 11 的当前 keywindow 等效项?
已弃用:
您尝试过Application.shared.keyWindow?.rootViewController
吗?keyWindow (或者如果你喜欢)是这里的重要部分。mainWindow
推荐阅读
- xamarin - 了解 Xamarin 表单中的数据绑定
- python - 指向此页面的 Django Like 按钮不起作用
- java - 以下哪一项是在 java 中调用用户定义类中存在的方法的更好的编程实践?
- flutter - 滚动时颤动水平列表视图点指示器
- c++ - 当我尝试在 C++ 中对谷物进行序列化时,我遇到了一个奇怪的错误
- java - 如何在 SpringBootTest 中加载不同的 application.properties 文件
- python - 一个 for 循环和 while 循环的问题。结果不是我所期望的
- python - 如何在 python pandas 中显示销售数据的每月变动?
- arduino - 如何阻止 if 语句重复?
- java - Eclipse 选项卡标题未正确显示