-
-
Save mattotodd/643e8b4b4a1305c4db8149fe666178ad to your computer and use it in GitHub Desktop.
Revisions
-
Jpoliachik created this gist
Dec 19, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // 1. init window self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; UIViewController *rootViewController = [UIViewController new]; // 2. backgroundView using LaunchScreen.xib UIView *backgroundView = [[[NSBundle mainBundle] loadNibNamed:@"LaunchScreen" owner:self options:nil] firstObject]; backgroundView.frame = self.window.bounds; // 3. ReactNative init NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil]; RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation moduleName:@"MyAwesomeApp" initialProperties:nil launchOptions:launchOptions]; // 4. rootView background clear, so our backgroundView can show until ReactNative has fully loaded rootView.backgroundColor = [UIColor clearColor]; // 5. set loadingView to the LaunchScreen.xib view too // explicitly set all frames UIView *launchScreenView = [[[NSBundle mainBundle] loadNibNamed:@"LaunchScreen" owner:self options:nil] firstObject]; rootView.frame = self.window.bounds; launchScreenView.frame = self.window.bounds; rootView.loadingView = launchScreenView; // 6. set the backgroundView as main view for the rootViewController (instead of the rootView) rootViewController.view = backgroundView; // 7. show self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible]; // 8. after the window is visible, add the rootView as a subview to your backgroundView [backgroundView addSubview:rootView]; return YES; }