可以在滚动视图上重用 UILabels 吗?

发布于 2024-08-19 12:43:03 字数 207 浏览 4 评论 0原文

我正在尝试实现一个在不使用 UITableView 的情况下显示信息网格的视图,但是,由于我要显示大约 36 个不同的统计数据,及其标签,我将必须初始化并使用 72 个 UILabels。拥有如此多的 UILabel 是否意味着我的 iPhone 应用程序的性能会受到显着的负面影响?有没有办法重用一些 UILabels 来减少必须一次加载的 UILabels 数量,或者我应该在表面上绘制所有内容?

I'm trying to implement a view that shows a grid of information without using a UITableView, however, since I'm displaying about 36 different statistics, with its label I will have to initialize and use 72 UILabels. Does having so many UILabels mean that my iPhone app's performance will be significantly negatively affected? Is there a way to reuse some of the UILabels to decrease the number of UILabels that must be loaded at one time, or should I just resort to drawing everything on a surface instead?

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

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

发布评论

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

评论(1

殊姿 2024-08-26 12:43:03

首先,您应该测试您想到的界面,看看它是否会影响性能。一次加载大量标签会增加您的内存占用量,但根据应用程序中发生的其他情况,这可能并不重要。

其次,您不能轻易地重复使用标签,但这是可能的。但是,您必须不断监视滚动视图的显示区域,并在视图滚动时移动标签框架。我怀疑你能否有效地做到这一点。无论如何,这都需要大量的编码。

第三,任何类似网格的布局都可以轻松地显示在表格中,而不会使其看起来像表格。例如,照片选择器布局是一个表格,但它看起来像白色背景上的一堆图标。我看到的另一个应用程序使用表格来显示文本段落,但它看起来像普通的滚动文本视图。表格中的每一行都可以自定义,以准确显示您想要的内容。原则上,您可以为每一行使用不同的单元格,并且它们的高度和内容都可以是唯一的。

该表的优点是该表可以为您管理屏幕上显示的内容和不显示的内容。它确实重用了单元格及其内容,这使得它们更加高效。该表还可以更轻松地管理大量数据。

First of all you should test the interface your thinking of and see if it takes a performance hit. Having a lot of labels all loaded at once will increase your memory footprint but depending on what else is going on in the app, it might not matter.

Secondly, you can't easily reuse the labels but it is possible. However, you would have to constantly monitor the displayed area of the scrollview and move the labels frames around as the view scrolled. I doubt you could do that efficiently. It would take a lot of coding in any case.

Thirdly, any grid like layout can be easily displayed in a table without making it look like a table. For example, the photopicker layout is a table but it looks like a bunch of icons on a white background. Another app I saw used a table to display paragraphs of text but it looked like an ordinary scrolling textview. Every row in a table can be customized to display exactly what you want. In principle, you could use a different cell for every row and they could all be unique in their height and contents.

The advantage of the table is the the table manages what is and is not on screen for you. It does reuse cells and their contents which makes them more efficient. The table also makes it easier to manage a lot of data.

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