From 8da7d6db968e40dadb06e9228954c15b91cf4be7 Mon Sep 17 00:00:00 2001 From: Nguyen Duc Binh Date: Sat, 16 Jun 2018 23:00:18 +0700 Subject: [PATCH 1/2] Update SplashScreen.m --- ios/SplashScreen.m | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/ios/SplashScreen.m b/ios/SplashScreen.m index 064c9933..f74d300b 100644 --- a/ios/SplashScreen.m +++ b/ios/SplashScreen.m @@ -12,6 +12,7 @@ static bool waiting = true; static bool addedJsLoadErrorObserver = false; +static UIView* loadingView = nil; @implementation SplashScreen - (dispatch_queue_t)methodQueue{ @@ -31,11 +32,28 @@ + (void)show { } } ++ (void)showSplash:(NSString*)splashScreen inRootView:(UIView*)rootView { + if (!loadingView) { + loadingView = [[[NSBundle mainBundle] loadNibNamed:splashScreen owner:self options:nil] objectAtIndex:0]; + CGRect frame = rootView.frame; + frame.origin = CGPointMake(0, 0); + loadingView.frame = frame; + } + waiting = false; + + [rootView addSubview:loadingView]; +} + + (void)hide { - dispatch_async(dispatch_get_main_queue(), - ^{ - waiting = false; - }); + if (waiting) { + dispatch_async(dispatch_get_main_queue(), ^{ + waiting = false; + }); + } else { + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [loadingView removeFromSuperview]; + }); + } } + (void) jsLoadError:(NSNotification*)notification From 60fd51f63968413d1bff6baf26f257544eb702a9 Mon Sep 17 00:00:00 2001 From: Nguyen Duc Binh Date: Sat, 16 Jun 2018 23:01:30 +0700 Subject: [PATCH 2/2] Update SplashScreen.h --- ios/SplashScreen.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ios/SplashScreen.h b/ios/SplashScreen.h index b182e0c5..d2a04a04 100644 --- a/ios/SplashScreen.h +++ b/ios/SplashScreen.h @@ -7,8 +7,10 @@ * Email:crazycodeboy@gmail.com */ #import +#import @interface SplashScreen : NSObject ++ (void)showSplash:(NSString*)splashScreen inRootView:(UIView*)rootView; + (void)show; + (void)hide; @end