IOS:选择UIScrollView或UITableView [英] IOS: choice a UIScrollView or a UITableView

查看:126
本文介绍了IOS:选择UIScrollView或UITableView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我应该创建一个包含大量信息的视图;
这些信息分为4个部分,每个部分可以包含文本,图像列表ecc ...

In my app I should create a view with a loto of informations; these informations are divided in 4 section, every section can contain text, images lists ecc...

这是一个残酷的例子...

this is a brutal example...

现在我对采用什么类型的解决方案表示怀疑。

Now I'm dubious to what type of solution to adopt.

在我看来,一个很大的卷轴视图很难组织起来。使用代码组织一个大的桌面视图很复杂......你有什么想法?

In a my fast opinion a big scrollview is difficult to organize. And a big tableview with section is complicated to organize with code... What are your ideas?

推荐答案

你应该选择 UITABLEVIEW ,易于管理易于理解,更多的可重用性和良好的内存管理

You should go with UITABLEVIEW, easy to manage easy to understand, more reusability and good memory management

如果您有大量内容需要滚动浏览, UITableView 可能会对您有所帮助保持内存使用率下降。

If you have lots of content to scroll through, a UITableView might help you with keeping memory usage down.

当一个单元格滚出视线时,它会从视图中移除并被 UITableView 供以后使用(通过 -dequeueReusableCellWithIdentifier:)。如果内存不足,我相信那些不可见的视图(UITableViewCells)将会被释放。这基本上意味着您的应用只会在内存中保留实际可见的视图。更多内容将被缓存,但可以在需要时随时清除。

When a cell scrolls out of sight, it gets removed from the view and kept around by the UITableView for later use (via -dequeueReusableCellWithIdentifier:). If you run low on memory then I believe that those invisible views (UITableViewCells) will get released. This basically means that your app will only keep views in memory that are actually visible. More will be cached, but can be purged any time if needed.

如果您显示大量数据,只需将其全部添加到 UIScrollView 与使用 UITableView 相比,它可能会占用更多内存。您可能必须实现类似于 UITableView 删除(并可能释放)不可见视图的机制。

If you display a lot of data, and just add it all to a UIScrollView it will potentially use much more memory than if you used a UITableView. You might have to implement a similar mechanism to what UITableView does to remove (and potentially release) invisible views.

所以,你基本上可以达到同样的效果,但 UITableView 已经为你做了很多工作。

So, you can basically achieve the same effect, but a UITableView does a lot of that work for you already.

如果您显示大量数据(可能超过两个屏幕已满),我倾向于使用 UITableView

If you display lots of data (probably more than about two screens full) I'd lean towards using a UITableView.

这篇关于IOS:选择UIScrollView或UITableView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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