为什么iOS启动屏幕很慢? [英] why is iOS launch screen very slow?

查看:40
本文介绍了为什么iOS启动屏幕很慢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的iOS应用启动屏幕大约需要3-5秒.我有一张将在启动屏幕后加载的地图.我的用户必须等待启动屏幕加载,然后再等待3秒钟才能加载地图.有没有一种方法可以最小化启动屏幕的时间?

My iOS app launch screen takes about 3 - 5 seconds. I have a map that will load after the launch screen. My users have to wait for the launch screen to load and then wait another 3 seconds for the map to load. Is there a way to minimize launch screen time?

推荐答案

基本上,此延迟表示在启动过程中做错了很多事情.您的工作是立即启动.确实,如果您不这样做,WatchDog应用程序将会杀死您.

Basically this delay means that you are doing something very wrong during launch. Your job is to launch immediately. Indeed, the WatchDog app will kill you dead if you don't.

关于此主题的WWDC精彩视频,您应该观看它们.但总的来说,有两种方法可以解决问题:

There are excellent WWDC videos on this topic, and you should watch them. But in general there are two ways to go wrong:

  • 您必须在主线程上不执行任何耗时的操作.如果您要进行耗时的工作(例如加载地图或联网),则必须在后台线程上进行.您需要摆脱困境,以便运行时可以启动您的应用程序 now .

  • You must do nothing time-consuming on the main thread. If you have a time-consuming thing to do, like loading your map or networking, you must do that on a background thread. You need to get out of the way so that the runtime can launch your app now.

相反,您必须不要触摸除主线程以外的任何其他线程上的接口.这样做是错误的,只会导致您要报告的延迟.在后台线程上完成您的工作,但是然后回到 main 线程上,与您的视图,视图控制器等进行对话.

Just the other way around, you must not touch the interface on any other thread but the main thread. Doing this wrong causes just the kind of delay you are reporting. Do your work on a background thread, but then get back on the main thread to talk to your views, view controllers, etc.

最后,我应该指出,您可能可以通过使用Instruments来了解一些错误信息.不幸的是,它在启动应用程序时效果很差,但是值得一试.首先,请观看这​​些视频!

Finally, I should point out that you might be able to get some idea what you're doing wrong by using Instruments. Unfortunately it works rather badly against app launch, but it can be worth a try. Above all, watch those videos!

这篇关于为什么iOS启动屏幕很慢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆