Browse Source

Revert "Use UIStoryboard methods for presenting a splash screen on iOS (#1453)" (#1457)

This reverts commit 36d2c7e35c.
Daniel Zlotin 7 years ago
parent
commit
2666cb1644
1 changed files with 27 additions and 15 deletions
  1. 27
    15
      ios/RCCManager.m

+ 27
- 15
ios/RCCManager.m View File

@@ -134,18 +134,28 @@
134 134
 -(void)showSplashScreen
135 135
 {
136 136
   CGRect screenBounds = [UIScreen mainScreen].bounds;
137
-  UIViewController *splashViewController = nil;
138
-
137
+  UIView *splashView = nil;
138
+  
139 139
   NSString* launchStoryBoard = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UILaunchStoryboardName"];
140 140
   if (launchStoryBoard != nil)
141 141
   {//load the splash from the storyboard that's defined in the info.plist as the LaunchScreen
142
-    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:launchStoryBoard bundle:[NSBundle mainBundle]];
143
-    splashViewController = [storyboard instantiateInitialViewController];
142
+    @try
143
+    {
144
+      splashView = [[NSBundle mainBundle] loadNibNamed:launchStoryBoard owner:self options:nil][0];
145
+      if (splashView != nil)
146
+      {
147
+        splashView.frame = CGRectMake(0, 0, screenBounds.size.width, screenBounds.size.height);
148
+      }
149
+    }
150
+    @catch(NSException *e)
151
+    {
152
+      splashView = nil;
153
+    }
144 154
   }
145 155
   else
146 156
   {//load the splash from the DEfault image or from LaunchImage in the xcassets
147 157
     CGFloat screenHeight = screenBounds.size.height;
148
-
158
+    
149 159
     NSString* imageName = @"Default";
150 160
     if (screenHeight == 568)
151 161
       imageName = [imageName stringByAppendingString:@"-568h"];
@@ -153,13 +163,13 @@
153 163
       imageName = [imageName stringByAppendingString:@"-667h"];
154 164
     else if (screenHeight == 736)
155 165
       imageName = [imageName stringByAppendingString:@"-736h"];
156
-
166
+    
157 167
     //xcassets LaunchImage files
158 168
     UIImage *image = [UIImage imageNamed:imageName];
159 169
     if (image == nil)
160 170
     {
161 171
       imageName = @"LaunchImage";
162
-
172
+      
163 173
       if (screenHeight == 480)
164 174
         imageName = [imageName stringByAppendingString:@"-700"];
165 175
       if (screenHeight == 568)
@@ -168,21 +178,23 @@
168 178
         imageName = [imageName stringByAppendingString:@"-800-667h"];
169 179
       else if (screenHeight == 736)
170 180
         imageName = [imageName stringByAppendingString:@"-800-Portrait-736h"];
171
-
181
+      
172 182
       image = [UIImage imageNamed:imageName];
173 183
     }
174
-
184
+    
175 185
     if (image != nil)
176 186
     {
177
-      UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
178
-      splashViewController = [[UIViewController alloc] init];
179
-      splashViewController.view = imageView;
187
+      splashView = [[UIImageView alloc] initWithImage:image];
180 188
     }
181 189
   }
182
-
183
-  if (splashViewController != nil) {
190
+  
191
+  if (splashView != nil)
192
+  {
193
+    UIViewController *splashVC = [[UIViewController alloc] init];
194
+    splashVC.view = splashView;
195
+    
184 196
     id<UIApplicationDelegate> appDelegate = [UIApplication sharedApplication].delegate;
185
-    appDelegate.window.rootViewController = splashViewController;
197
+    appDelegate.window.rootViewController = splashVC;
186 198
     [appDelegate.window makeKeyAndVisible];
187 199
   }
188 200
 }