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

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

问题描述

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

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天全站免登陆