preface

Launchscreen. storyboard must be launched with iOS13 by April of this year. Instead of using assert to launch, let’s talk about some of the issues we’ve had and how to resolve them.

The use of LaunchScreen. The storyboard

  1. Create a storyboard called LaunchScreen
  2. Under the LaunchScreen File option under the project Target, select the LaunchScreen you just created
  3. Go to buildSetting and search for “launch Image set Name” to remove the configuration
  4. Delete LaunchImage from image. asset

To run the project, use launchscreen.storyboard as the launch diagram

Problems encountered

1. A single startup diagram cannot meet the requirements of various models

The first attempt is to directly use a full-screen picture as the boot image, but this method can not meet the adaptation of various models, different screen display is different, can not meet the basic visual requirements.

So use a combination of multiple controls as a start diagram, this way can solve some stretching deformation, logo display position and other problems, the following is my start diagram constraints, you can also according to your business needs, to do start diagram constraints.

2. The startup diagram cannot be replaced in real time or a blank page can be displayed

For this problem, place the image resources used for the launch page in the project file directory, not in imageAsset.

Another situation I found when TESTING myself was that some models with bangs could not be replaced in real time even if they were placed in the project file directory.

According to the information, every time you change the startup image, you should change the name of the image, or delete the storyboard, clean project, etc., but these methods cannot solve the problem effectively. The only effective way is to delete the reloaded app, but obviously you can’t ask users to do this.

In launchscreen. storyboard, apple caches a screenshot of the launchscreen. storyboard app in the sandbox /Library/SplashBoard directory. The startup diagram cannot be updated in time. So we decided to clear the cache every time the app started.

In order to be called every time, I did this operation on the middle page after the app was started. The code is as follows:

// In order to read the latest startup graph every time, we need to clear the cache when there is a cache,  - (void)removeLaunchScreenCacheIfNeeded { NSString *filePath = [NSString stringWithFormat:@"%@/Library/SplashBoard", NSHomeDirectory()]; if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) { NSError *error = nil; [[NSFileManager defaultManager] removeItemAtPath:filePath error:&error]; If (error) {NSLog(@" LaunchScreen cache failed "); } else {NSLog(@" LaunchScreen cache cleared successfully "); }}}Copy the code

It is the first time to write an article.