From a3be849192ebb451c2d36d21354f1fa125aa52aa Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Wed, 29 May 2024 02:05:40 -0700 Subject: [PATCH] refactor: Remove outdated app init code from CDVAppDelegate The template's storyboard should handle the initialization of the view controller, rather than constructing it manually here. --- CordovaLib/Classes/Public/CDVAppDelegate.m | 23 ------------------- .../CordovaLibApp/AppDelegate.m | 8 ++++++- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/CordovaLib/Classes/Public/CDVAppDelegate.m b/CordovaLib/Classes/Public/CDVAppDelegate.m index 483c8d45e8..d0605f9117 100644 --- a/CordovaLib/Classes/Public/CDVAppDelegate.m +++ b/CordovaLib/Classes/Public/CDVAppDelegate.m @@ -35,31 +35,8 @@ - (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions: return YES; } -/** - * This is main kick off after the app inits, the views and Settings are setup here. (preferred - iOS4 and up) - */ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - CGRect screenBounds = [[UIScreen mainScreen] bounds]; - - self.window = [[UIWindow alloc] initWithFrame:screenBounds]; - self.window.autoresizesSubviews = YES; - - // only set if not already set in subclass - if (self.viewController == nil) { - self.viewController = [[CDVViewController alloc] init]; - } - - // Set your app's start page by setting the tag in config.xml. - // If necessary, uncomment the line below to override it. - // self.viewController.startPage = @"index.html"; - - // NOTE: To customize the view's frame size (which defaults to full screen), override - // [self.viewController viewWillAppear:] in your view controller. - - self.window.rootViewController = self.viewController; - [self.window makeKeyAndVisible]; - return YES; } diff --git a/tests/CordovaLibTests/CordovaLibApp/AppDelegate.m b/tests/CordovaLibTests/CordovaLibApp/AppDelegate.m index 9952ad8721..2785795c22 100644 --- a/tests/CordovaLibTests/CordovaLibApp/AppDelegate.m +++ b/tests/CordovaLibTests/CordovaLibApp/AppDelegate.m @@ -40,7 +40,8 @@ - (void)createViewController // NOTE: To customize the view's frame size (which defaults to full screen), override // [self.viewController viewWillAppear:] in your view controller. - self.window.rootViewController = _viewController; + _window.rootViewController = _viewController; + [_window makeKeyAndVisible]; } - (void)destroyViewController @@ -51,6 +52,11 @@ - (void)destroyViewController - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { BOOL retVal = [super application:application didFinishLaunchingWithOptions:launchOptions]; + + CGRect screenBounds = [[UIScreen mainScreen] bounds]; + _window = [[UIWindow alloc] initWithFrame:screenBounds]; + _window.autoresizesSubviews = YES; + // Create the main view on start-up only when not running unit tests. if (!NSClassFromString(@"CDVWebViewTest")) { [self createViewController];