500 个标签的内存管理
我有一个视图,上面有数百个单独的 UILabel。它有效,但显然是系统上的一个沼泽。该应用程序运行缓慢,直到另一种方法释放此视图以及所有标签。
但是,我知道经常需要在屏幕上放置这么多文本,所以我想知道如何更好地做到这一点。每个标签都根据其他参数放置在特定位置,因此它不能只是一个大文本视图。
我猜想更好的方法是使用 Open GL 字体或类似的东西在屏幕上“绘制”文本。还有其他建议或建议吗?
I have a view with several hundred individual UILabel
s on it. It works, but it is clearly a bog on the system. The app is sluggish until another method releases this view with all the labels.
However, I know that it is necessary often to put this amount of text on a screen, so I'm wondering how is a better way to do it. The labels are each placed in a specific location based on other parameters, so it cannot just be one big textview.
I am guessing the better way to do this is to "draw" the text on the screen using an Open GL Font or something like that. Any other suggestions or advice?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您还可以检查 NSString 的添加: NSString UIKit添加
示例用法:
You can also check Additions to NSString: NSString UIKit Additions
Sample usage:
使用 Core Graphics 将文本绘制到
drawRect
方法中的CGContext
上。请参阅 CGContext 文档<的绘图文本部分< /a>Use Core Graphics to draw the text onto the
CGContext
in yourdrawRect
method. See the Drawing Text section of the CGContext docs