Skip to content

Commit

Permalink
Show the Launch Screen until React has finished loading
Browse files Browse the repository at this point in the history
The Launch Screen is only shown until the app has loaded, not until
React has loaded. This results in a white flash between the Launch
Screen and the initial view of the app. This commit fixes that by
showing the Launch Screen until React also has finished loading.

The solution was found here:
facebook/react-native#1402 (comment)
  • Loading branch information
timothyej committed Apr 7, 2018
1 parent 0eb5394 commit fe71cc6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ios/WalletID/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];

UIView* launchScreenView = [[[NSBundle mainBundle] loadNibNamed:@"LaunchScreen" owner:self options:nil] objectAtIndex:0];
launchScreenView.frame = self.window.bounds;
rootView.loadingView = launchScreenView;

return YES;
}

Expand Down

2 comments on commit fe71cc6

@markgibaud
Copy link

@markgibaud markgibaud commented on fe71cc6 Jun 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And if you're not using a .xib but rather images (asset catalogue) then the following code can be used:

NSArray *allPngImageNames = [[NSBundle mainBundle] pathsForResourcesOfType:@"png" inDirectory:nil];
  for (NSString *imgName in allPngImageNames){
    if ([imgName containsString:@"LaunchImage"]){
      UIImage *img = [UIImage imageNamed:imgName];
      
      if (img.scale == [UIScreen mainScreen].scale && CGSizeEqualToSize(img.size, [UIScreen mainScreen].bounds.size)) {
        rootView.backgroundColor = [UIColor colorWithPatternImage:img];
      }
    }
  }

@timothyej
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using a .xib, but thanks for the tip anyway :)

Please sign in to comment.