iOS-像Path这样的应用程序如何优化每个单元格(几乎)不同的表单元格? [英] iOS - How do apps like Path optimize their table cells where every cell is (almost) different?

查看:73
本文介绍了iOS-像Path这样的应用程序如何优化每个单元格(几乎)不同的表单元格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以这是我当前遇到的问题.

我有一个应用程序,可显示带有UITableView的Facebook/Path之类的供稿.假设我的数据源有大约200个项目,并且并非所有单元格都具有相同的内容和单元格高度.有些有图片,有些则没有.我可以通过使用以下格式的可重复使用的标识符初始化单元格来克服滚动性能问题:[NSString stringWithFormat:"entry_%d",some_id].在开始使用UIImagePickerViewController之前,事情进展得非常顺利.可以想象,由于数据源/表很大,我收到了很多内存警告.

在使用Path的应用程序并尝试将尽可能多的数据加载到单个视图中时;他们在滚动性能和内存管理方面都做得非常好.每当我进入相机模式时,他们的应用也不会崩溃.

有什么想法或理论吗?

谢谢! :)

解决方案

我强烈建议您检查一下可重新实现表格视图的Facebook iOS框架.框架的名称为Three20,您可以在github 此处找到它.

话虽如此,如果您有一个非常大的表,则需要小心,仅为可见的那些对象加载资源,并在它们消失后释放它们的资源.委托方法tableView:didEndDisplayingCell:forRowAtIndexPath:(在iOS 6和更高版本中可用)是您的朋友. 这是与此主题相关的另一个问题. /p>

So here's the issue i'm currently running into.

I have an app that shows a Facebook/Path like feed with a UITableView. Let's say that my datasource has about 200 items and not all cells have the same content and cell height. Some have images and some don't. I was able to overcome the scrolling performance issue by initializing my cells with a reusable identifier in the following format: [NSString stringWithFormat:"entry_%d", some_id]. Things were going really well up until I started using the UIImagePickerViewController. As you can imagine I've been receiving a lot of memory warnings due to my large datasource/table.

When playing with the Path's app and trying to load as many data into a single view; they do a really good job at both the scrolling performance and memory management. Their app also doesn't crash whenever I go into the camera mode.

Any thoughts or theories?

Thanks! :)

解决方案

I highly suggest you check out the Facebook iOS framework which reimplements the table view. The name of the framework is Three20, and you can find it on github here.

With that said, if you have a very large table, you need to be careful to only load resources for those things that are in view, and release resources for items once they go out of view. The delegate method tableView:didEndDisplayingCell:forRowAtIndexPath: (available iOS 6 and later) is your friend for that. Here is another question related to this topic.

这篇关于iOS-像Path这样的应用程序如何优化每个单元格(几乎)不同的表单元格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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