我的app启动页面是用的图片,如下图。
但是每次启动的时候,启动图片结束后会黑屏1秒左右才进入主页面,这是为什么呢?
而且奇怪的是,并不是次次都黑屏,有时候又不黑屏。
ringa_lee2017-04-18 09:15:32
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.
PHP中文网2017-04-18 09:15:32
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.
PHP中文网2017-04-18 09:15:32
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.
伊谢尔伦2017-04-18 09:15:32
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
PHP中文网2017-04-18 09:15:32
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor = [UIColor whiteColor];
self.window.rootViewController = XXX;
[self.window makeKeyAndVisible];
ringa_lee2017-04-18 09:15:32
Is it that the startup page corresponding to the device screen size has not been added
迷茫2017-04-18 09:15:32
The startup page is not loaded, don’t use lanuchimage, create a StoryBoard and spread the pictures on it, it will be ok
迷茫2017-04-18 09:15:32
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.