mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 18:35:34 +00:00
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:
@@ -2,7 +2,5 @@
|
|||||||
|
|
||||||
#include <UIKit/UIKit.h>
|
#include <UIKit/UIKit.h>
|
||||||
|
|
||||||
@interface GioAppDelegate : UIResponder <UIApplicationDelegate>
|
@interface GioViewController : UIViewController
|
||||||
@property (strong, nonatomic) UIWindow *window;
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|||||||
@@ -11,30 +11,9 @@
|
|||||||
@interface GioView: UIView <UIKeyInput>
|
@interface GioView: UIView <UIKeyInput>
|
||||||
@end
|
@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
|
@implementation GioViewController
|
||||||
CGFloat _keyboardHeight;
|
|
||||||
|
|
||||||
+ (UIWindow *)createWindow {
|
CGFloat _keyboardHeight;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)loadView {
|
- (void)loadView {
|
||||||
gio_runMain();
|
gio_runMain();
|
||||||
@@ -47,7 +26,6 @@ CGFloat _keyboardHeight;
|
|||||||
#ifndef TARGET_OS_TV
|
#ifndef TARGET_OS_TV
|
||||||
drawView.multipleTouchEnabled = YES;
|
drawView.multipleTouchEnabled = YES;
|
||||||
#endif
|
#endif
|
||||||
drawView.contentScaleFactor = self.screen.nativeScale;
|
|
||||||
drawView.preservesSuperviewLayoutMargins = YES;
|
drawView.preservesSuperviewLayoutMargins = YES;
|
||||||
drawView.layoutMargins = UIEdgeInsetsMake(0, 0, 0, 0);
|
drawView.layoutMargins = UIEdgeInsetsMake(0, 0, 0, 0);
|
||||||
onCreate((__bridge CFTypeRef)drawView);
|
onCreate((__bridge CFTypeRef)drawView);
|
||||||
@@ -156,6 +134,7 @@ NSArray<UIKeyCommand *> *_keyCommands;
|
|||||||
name:UIWindowDidResignKeyNotification
|
name:UIWindowDidResignKeyNotification
|
||||||
object:self.window];
|
object:self.window];
|
||||||
}
|
}
|
||||||
|
self.contentScaleFactor = newWindow.screen.nativeScale;
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
selector:@selector(onWindowDidBecomeKey:)
|
selector:@selector(onWindowDidBecomeKey:)
|
||||||
name:UIWindowDidBecomeKeyNotification
|
name:UIWindowDidBecomeKeyNotification
|
||||||
|
|||||||
@@ -163,6 +163,20 @@ func exeIOS(tmpDir, target, app string, bi *buildInfo) error {
|
|||||||
const mainmSrc = `@import UIKit;
|
const mainmSrc = `@import UIKit;
|
||||||
@import Gio;
|
@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[]) {
|
int main(int argc, char * argv[]) {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
return UIApplicationMain(argc, argv, nil, NSStringFromClass([GioAppDelegate class]));
|
return UIApplicationMain(argc, argv, nil, NSStringFromClass([GioAppDelegate class]));
|
||||||
|
|||||||
Reference in New Issue
Block a user