何时使用UICollectionView而不是UITableView? [英] When to use UICollectionView instead of UITableView?

查看:113
本文介绍了何时使用UICollectionView而不是UITableView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现 UICollectionView 就像在iOS6中引入的 UITableView 的升级版本,但我什么时候应该选择 UICollectionView 而不是 UITableView

I found that UICollectionView is like an upgraded version of UITableView introduced in iOS6, but when should I choose UICollectionView instead of UITableView?

如果 UICollectionView ,仍有使用 UITableView 的应用程序可以做什么 UITableView 可以做,为什么人们仍然使用 UITableView ?就性能而言是否存在差异?

There are still Apps using UITableView, if UICollectionView can do anything UITableView can do , why people still use UITableView? Is there a difference as far as performance is concerned?

谢谢!

推荐答案

这取决于要求。应用程序流如何确定要集成到应用程序中的UI类型。

That depends on the requirements. How the application flows determines which type of UI to integrate into the application.

人们主要使用 UICollectionview 来创建网格中显示多个图像的UI类型。这将使用 UITableView 进行复杂的逻辑,但是使用 UICollectionview ,这将很容易。

People mainly use the UICollectionview for creating types of UIs with multiple images shown in a grid. This would have complex logic using UITableView, but with UICollectionview, it would be easy.

使用 UICollectionview 时,您无需通过获取所选项目值来设置带有标签或其他内容的按钮。您只需获取 - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath 并在 UITableViewDelegate

When using UICollectionview, you don't need to set buttons with tags or other things by getting selected items values. You can simply get -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath and in UITableViewDelegate:

`-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath`

您将获得所选行而不是项目,因此,使用创建网格或修改的项目UICollectionview 是最好的。

You get the selected row instead of the item, so for creating grid or modified items, using UICollectionview is best.

对于每个项目的列表细节,人们使用 UITableView 因为它显示了每个项目的更多信息。

For the listing details of each item, people use UITableView because it shows more info on each item.

Apple文档:

< a href =https://developer.apple.com/library/ios/documentation/uikit/reference/UICollectionView_class/Reference/Reference.html> UICollectionView类参考


UICollectionView类管理有序的数据项集合,并使用可自定义的布局呈现它们。集合视图提供与表视图相同的常规功能,除了集合视图能够支持的不仅仅是单列布局。集合视图支持可自定义的布局,可用于实现多列网格,平铺布局,圆形布局等等。如果需要,您甚至可以动态更改集合视图的布局。

The UICollectionView class manages an ordered collection of data items and presents them using customizable layouts. Collection views provide the same general function as table views except that a collection view is able to support more than just single-column layouts. Collection views support customizable layouts that can be used to implement multi-column grids, tiled layouts, circular layouts, and many more. You can even change the layout of a collection view dynamically if you want.

UITableView类参考


表视图显示单个列中的项列表。 UITableView是UIScrollView的子类,它允许用户滚动表,尽管UITableView只允许垂直滚动。包含表的各个项的单元格是UITableViewCell对象; UITableView使用这些对象来绘制表的可见行。单元格具有内容标题和图像,并且可以在右边缘附近具有附件视图。标准附件视图是公开指示器或详细公开按钮;前者导致数据层次结构中的下一级别,后者导致所选项目的详细视图。附件视图也可以是框架控件,例如开关和滑块,或者可以是自定义视图。表视图可以进入编辑模式,用户可以在其中插入,删除和重新排序表的行。

A table view displays a list of items in a single column. UITableView is a subclass of UIScrollView, which allows users to scroll through the table, although UITableView allows vertical scrolling only. The cells comprising the individual items of the table are UITableViewCell objects; UITableView uses these objects to draw the visible rows of the table. Cells have content—titles and images—and can have, near the right edge, accessory views. Standard accessory views are disclosure indicators or detail disclosure buttons; the former leads to the next level in a data hierarchy and the latter leads to a detailed view of a selected item. Accessory views can also be framework controls, such as switches and sliders, or can be custom views. Table views can enter an editing mode where users can insert, delete, and reorder rows of the table.

这篇关于何时使用UICollectionView而不是UITableView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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