swift - iOS启动页面之后会黑屏1秒左右才进入主画面
大家讲道理
大家讲道理 2017-04-18 09:13:32
0
9
769

我的app启动页面是用的图片,如下图。

但是每次启动的时候,启动图片结束后会黑屏1秒左右才进入主页面,这是为什么呢?
而且奇怪的是,并不是次次都黑屏,有时候又不黑屏。

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(9)
左手右手慢动作

I found the reason. When the loaded home page is initialized, there is a data reading operation that is performed synchronously, which will block the UI thread and cause the UI to briefly black screen. Just change it to asynchronous.

Ty80

I suspect it took too long.

You can print the timestamp on the didFinishLaunchingWithOptions first line of appDelegate and the timestamp of viewDidAppear on the home page to see if the difference between the two is too long. Are there any time-consuming operations on the main thread, such as reading and writing databases, loading large files, etc.

Ty80

Occasional bugs are more difficult to deal with. Did the ViewController of the first interface do anything to block the main thread before ViewAppear?
If not, you can first try assigning LaunchScreen to a StoryBoard file and then fill the LaunchScreen with pictures.

PHPzhong

Is the rootViewController of your window set?

伊谢尔伦

The black screen means that your rootVC interface is not displayed, or it is black or empty. It is recommended to set the view of rootVC to an eye-catching color, such as red, and check the situation

Ty80

self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor = [UIColor whiteColor];
self.window.rootViewController = XXX;
[self.window makeKeyAndVisible];

左手右手慢动作

Is it that the startup page corresponding to the device screen size has not been added

迷茫

The startup page is not loaded, don’t use lanuchimage, create a StoryBoard and spread the pictures on it, it will be ok

迷茫

I also have the same problem. The LaunchImage shows that when the program is re-awakened, the page comes out and the screen flashes black.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template