简体   繁体   English

首次启动后,启动屏幕没有出现吗?

[英]Launch screen doesn't show first after the first launch time?

I am developing App with React native . 我正在使用React native开发App。
I set an image in the launchScreen.Xib . 我在launchScreen.Xib设置图像。
The first time, the launch screen works well. 第一次,启动屏幕运行良好。 After the launch screen hide, then I will see the View MainView . 隐藏启动屏幕后,然后将看到View MainView
I shut up the App in the background. 我在后台关闭了该应用程序。 A moment later, I tap the App icon to launch the App again. 片刻之后,我点击“应用程序”图标再次启动该应用程序。
To my surprise, the App will show the MainView first, the MainView continue show 0.2 seconds. 令我惊讶的是,该应用程序将首先显示MainView ,MainView继续显示0.2秒。

After the MainView flash, the launch screen show now. MainView闪烁后,现在显示启动屏幕。 A few seconds later, the MainView show again. 几秒钟后, MainView再次显示。
My issue is the MainView will show before the launch screen in the later launch time. 我的问题是MainView将在以后的启动时间中显示在启动屏幕之前。

In my opinion, the launch screen should show first and the MainView show later. 我认为启动屏幕应首先显示,而MainView应随后显示。

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation;

  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];

  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"patient"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  return YES;
}

This is my code above in the AppDelegate.m . 这是我上面AppDelegate.m代码。 This is the initial code of React native . 这是React native的初始代码。

One more thing, the MainView show a moment, and the screen shows a white view instead of the MainView , a moment later, the MainView show again. 再说一遍, MainView显示了片刻,屏幕显示了白色视图,而不是MainView ,片刻之后,再次显示了MainView

Well, you're trying to instantiate and show with timer your own launch screen (not good!) while also asking iOS to do one. 好吧,您正在尝试实例化并使用计时器显示您自己的启动屏幕(不好!),同时还要求iOS做一个。 Just get rid of most or all of this code. 只是摆脱大多数或所有这些代码。 Use the standard approach of having a launch storyboard then set up your main VC as normal in your appDelegate. 使用具有启动故事板的标准方法,然后在appDelegate中正常设置主VC。

Using that timer is making assumptions about the timing of each app launch that iOS can't guarantee. 使用该计时器是对iOS无法保证的每个应用程序启动时间的假设。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM