I\'m converting my iOS13 app for iPadOS to SceneDelegate (multi window).
How can I get the current UIWindow from the current SceneDelegate?
I know that a can
Now you have more than one window, one for each scene. First, you have to answer which one you need at the moment of usage.
Probably you want to get the window of the currently active scene then you can use this:
UIWindow* window = nil;
if (@available(iOS 13.0, *))
{
for (UIWindowScene* wScene in [UIApplication sharedApplication].connectedScenes)
{
if (wScene.activationState == UISceneActivationStateForegroundActive)
{
window = wScene.windows.firstObject;
break;
}
}
}