app/internal/window,cmd/gogio: [iOS] export GioViewController

The Gio GioAppDelegate created the GioViewController programmatically.
When using gogio's -buildmode=archive users may want to use a different
method (for example storyboards) but there can only be one app delegate.

Move the GioAppDelegate to gogio's exe buildmode, and export the
GioViewController for embedding use.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-06-26 15:47:00 +02:00
parent 79014a81d5
commit d97f7f9093
3 changed files with 17 additions and 26 deletions
+1 -3
View File
@@ -2,7 +2,5 @@
#include <UIKit/UIKit.h>
@interface GioAppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@interface GioViewController : UIViewController
@end
+2 -23
View File
@@ -11,30 +11,9 @@
@interface GioView: UIView <UIKeyInput>
@end
@interface GioViewController : UIViewController
@property(weak) UIScreen *screen;
+ (UIWindow *)createWindow;
@end
@implementation GioAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [GioViewController createWindow];
[self.window makeKeyAndVisible];
return YES;
}
@end
@implementation GioViewController
CGFloat _keyboardHeight;
+ (UIWindow *)createWindow {
UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
GioViewController *controller = [[self alloc] initWithNibName:nil bundle:nil];
controller.screen = window.screen;
window.rootViewController = controller;
return window;
}
CGFloat _keyboardHeight;
- (void)loadView {
gio_runMain();
@@ -47,7 +26,6 @@ CGFloat _keyboardHeight;
#ifndef TARGET_OS_TV
drawView.multipleTouchEnabled = YES;
#endif
drawView.contentScaleFactor = self.screen.nativeScale;
drawView.preservesSuperviewLayoutMargins = YES;
drawView.layoutMargins = UIEdgeInsetsMake(0, 0, 0, 0);
onCreate((__bridge CFTypeRef)drawView);
@@ -156,6 +134,7 @@ NSArray<UIKeyCommand *> *_keyCommands;
name:UIWindowDidResignKeyNotification
object:self.window];
}
self.contentScaleFactor = newWindow.screen.nativeScale;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(onWindowDidBecomeKey:)
name:UIWindowDidBecomeKeyNotification
+14
View File
@@ -163,6 +163,20 @@ func exeIOS(tmpDir, target, app string, bi *buildInfo) error {
const mainmSrc = `@import UIKit;
@import Gio;
@interface GioAppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
@implementation GioAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
GioViewController *controller = [[GioViewController alloc] initWithNibName:nil bundle:nil];
self.window.rootViewController = controller;
[self.window makeKeyAndVisible];
return YES;
}
@end
int main(int argc, char * argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([GioAppDelegate class]));