Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions addons/ofxiOS/src/app/ofAppiOSWindow.mm
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,69 @@
#include "ofxiOSGLKView.h"
#include "ofxiOSEAGLView.h"

@interface ofxiOSSceneDelegate : UIResponder <UIWindowSceneDelegate>
@property (strong, nonatomic) UIWindow * window;
@end

@implementation ofxiOSSceneDelegate

- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
if (![scene isKindOfClass:[UIWindowScene class]]) return;
id<UIApplicationDelegate> appDelegate = [UIApplication sharedApplication].delegate;
if ([appDelegate respondsToSelector:@selector(window)]) {
self.window = appDelegate.window;
}
if (self.window) {
self.window.windowScene = (UIWindowScene *)scene;
[self.window makeKeyAndVisible];
}
[self scene:scene openURLContexts:connectionOptions.URLContexts];
}

- (void)sceneDidBecomeActive:(UIScene *)scene {
[self forward:@selector(applicationDidBecomeActive:)];
}

- (void)sceneWillResignActive:(UIScene *)scene {
[self forward:@selector(applicationWillResignActive:)];
}

- (void)sceneWillEnterForeground:(UIScene *)scene {
[self forward:@selector(applicationWillEnterForeground:)];
}

- (void)sceneDidEnterBackground:(UIScene *)scene {
[self forward:@selector(applicationDidEnterBackground:)];
}

- (void)scene:(UIScene *)scene openURLContexts:(NSSet<UIOpenURLContext *> *)URLContexts {
id<UIApplicationDelegate> appDelegate = [UIApplication sharedApplication].delegate;
for (UIOpenURLContext * context in URLContexts) {
if ([appDelegate respondsToSelector:@selector(application:openURL:options:)]) {
[appDelegate application:[UIApplication sharedApplication] openURL:context.URL options:@{}];
}
else if ([appDelegate respondsToSelector:@selector(application:handleOpenURL:)]) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[appDelegate application:[UIApplication sharedApplication] handleOpenURL:context.URL];
#pragma clang diagnostic pop
}
}
}

// calls the app delegate's application...: method for a scene event
- (void)forward:(SEL)selector {
id<UIApplicationDelegate> appDelegate = [UIApplication sharedApplication].delegate;
if ([appDelegate respondsToSelector:selector]) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[appDelegate performSelector:selector withObject:[UIApplication sharedApplication]];
#pragma clang diagnostic pop
}
}

@end

//----------------------------------------------------------------------------------- instance.
static ofAppiOSWindow * _instance = NULL;
ofAppiOSWindow * ofAppiOSWindow::getInstance() {
Expand Down
17 changes: 17 additions & 0 deletions scripts/templates/ios/ofxiOS-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,22 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default</string>
<key>UISceneDelegateClassName</key>
<string>ofxiOSSceneDelegate</string>
</dict>
</array>
</dict>
</dict>
</dict>
</plist>
17 changes: 17 additions & 0 deletions scripts/templates/tvOS/ofxtvOS-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,22 @@
<array>
<string>arm64</string>
</array>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default</string>
<key>UISceneDelegateClassName</key>
<string>ofxiOSSceneDelegate</string>
</dict>
</array>
</dict>
</dict>
</dict>
</plist>
Loading