'Use of scene delegate for apps that does not support multiple windows
I know that scene delegate can only be used on iOS 13 and later. For my app to support iOS 12 and earlier versions, its either I opt-out of scene delegate or set @available tag to remind Xcode. I read about the use of scene delegate here. Based on what I see, aside from supporting multiple windows, I am not aware of any other advantage of using scene delegate on apps that DOES NOT support multiple windows. Will there be a boost in performance? So, can I just use App Delegate alone if my app does not plan on supporting multiple windows in the future?
Solution 1:[1]
windows are managed by WindowScene
,
you need register your new window ( multiple windows ) to WindowScene
, with SceneDelegate
YourWindow * window = [[YourWindow alloc] initWithFrame:CGRectMake(0, 0, windowWidth, windowWidth)];
window.hidden = false
// there is a time delay,
// if activationState = UISceneActivationStateUnattached
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (@available(iOS 13.0, *)) {
for (UIWindowScene *windowScene in [UIApplication sharedApplication].connectedScenes) {
if (windowScene.activationState == UISceneActivationStateForegroundActive) {
window.windowScene = windowScene ;
break;
}
}
}
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | dengST30 |