gpt4 book ai didi

iphone - 当我点击 iPhone 应用程序图标时到底发生了什么?

转载 作者:行者123 更新时间:2023-12-03 20:22:20 25 4
gpt4 key购买 nike

我的应用程序加载时间非常长,我不知道为什么。添加:在实际调出 Default@2x.png 之前,它会在主屏幕上卡住 3-4 秒。

有人可以告诉我点击图标时正在加载什么吗?是applicationDidFinishLaunching方法吗?还是资源?

最佳答案

作为一个非常笼统的答案:Apple 在 The Application Life Cycle 部分详细介绍了这一点iOS 应用程序编程指南。

值得注意的是本节中的第一个图表。介绍性段落后面的流程图相当不言自明(强调我的目的是为了解决您的具体问题):

The application life cycle constitutes the sequence of events that occurs between the launch and termination of your application. In iOS, the user launches your application by tapping its icon on the Home screen. Shortly after the tap occurs, the system displays some transitional graphics and proceeds to launch your application by calling its main function. From this point on, the bulk of the initialization work is handed over to UIKit, which loads the application’s main nib file and readies the event loop.


(source: apple.com)

至于为什么您的应用程序加载缓慢,您没有提供任何其他信息,所以我只能说检查您的 Nib 中正在加载哪些资源,

  • 图像很大还是很多?

并查看应用程序委托(delegate)的 application:didFinishLaunchingWithOptions: 方法及其可能调用的相关设置例程,

  • 如果您有任何数据加载例程,它们是否会获取应用程序文档目录中的所有内容(例如)并将它们一下子加载到内存中?

  • 您的数据是如何存储的?平面/简单文件(例如 XML 或 plist)可能听起来没什么大不了的,因为它们只是基本的 I/O,但当涉及大型数据存储或复杂的对象关系时,Core Data 或 SQLite 往往性能更优越。

此外,Instruments 是您的 friend 。

关于iphone - 当我点击 iPhone 应用程序图标时到底发生了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5283754/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com