以编程方式分配接口对象会影响加载时间吗?

发布于 2025-01-02 20:17:42 字数 340 浏览 6 评论 0原文

我正在制作一个应用程序,可以让您快速更改亮度,但由于功能不足而被拒绝,因此我将其与我的电池应用程序合并。如果我只加载亮度内容并有一个按钮显示“加载应用程序的其余部分”,按下该按钮时,将加载界面的其余部分,如下所示:

(IBOutlet 之前制作)

batterymeter = [[UIImageView alloc] initWithFrame:CGRectMake(150,300,250,50)];
batterymeter.image = [UIImage imageNamed:@"batteryfill.png"];

会减慢加载时间吗?如果没有,我该如何加载半个界面?

I'm making an app that allows you to quickly change your brightness, but that was rejected for not having enough features, so I'm merging it with my battery app. If I only load the brightness stuff and have a button that says "load rest of app", which when pressed, loads the rest of the interface as below:

(IBOutlet previously made)

batterymeter = [[UIImageView alloc] initWithFrame:CGRectMake(150,300,250,50)];
batterymeter.image = [UIImage imageNamed:@"batteryfill.png"];

will that slow down the loading time? If not, how could I go about loading half an interface?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浴红衣 2025-01-09 20:17:42

以编程方式构建 UI 可以减少加载时间。从磁盘读取的内容更少,解析的内容也更少,并且您可以编写加载速度更快的实现。

NIB 也可以被缓存以弥补这一差距。

对于许多应用程序来说,这并不重要——只需使用最适合设计的东西即可(如果您最熟悉的话,可能是 NIB)。对于复杂或性能关键的应用程序,程序化创建通常是最佳选择。对于真正的大型应用程序,还有许多其他考虑因素。

您可以仅使用单独的 NIB 或编程实现来执行部分加载。然而,在任何一种情况下,加载时间都不应该明显长。如果是的话,请查看分析器向您显示的内容。

Constructing your UIs programmatically can reduce load times. There's less to read from disk, less to parse, and you can write an implementation which loads faster.

NIBs may also be cached to close that gap.

For many applications, it wont matter -- just use what fits the design best (that may be NIBs if that is what you are most familiar with). For complicated or performance critical apps, programmatic creation is often the way to go. For really large apps, there are a number of other considerations.

You can just use separate NIBs or programmatic implementations to do partial loads. However, load times should not be noticeably long in either case. If it is, then see what the profiler shows you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文