I found that
UICollectionView is like an upgraded version of
UITableView introduced in iOS6, but when should I choose
UICollectionView instead of
There are still Apps using
UICollectionView can do anything
UITableView can do , why people still use
UITableView? Is there a difference as far as performance is concerned?
That depends on the requirements. How the application flows determines which type of UI to integrate into the application.
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, 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
`-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath`
You get the selected row instead of the item, so for creating grid or modified items, using
UICollectionview is best.
For the listing details of each item, people use
UITableView because it shows more info on each item.
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.
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.
For simple lists and forwards/backwards navigtaion, use
If you need a high degree of customisability, use
Generally speaking, in software development, it’s best to choose the approach which represents “The Simplest Possible Thing”.
Here’s my criteria:
If a UITableView can do it, use it
If a UITableView needs lots of code to do it or can’t do it at all, use UICollectionView.
You have to consider the restrictions on UITableView before making a decision: It’s a single column. And you can only customize the cells, but not section backgrounds and such. So if you have a straight-up list of things with no extra frills – that looks like a bog standard iOS view, basically – then use UITableview. If you have custom insets, or a border around each section, use UICollectionView.
I’m actually considering UICollectionView for all things simply because it’s very expensive when you start developing your view as a table view, then later find out it can’t do that one thing that you need it to do. 1st hand experience 😉
Edit after even more experience with the two: Disregard that last paragraph. UICollectionView requires a lot of boilerplate code to make it work like a UITableView. Use UICollectionView only when really needed. 😉
According to my point of view main difference between collectionView and tableView is that
TABLEVIEW –> show list of items in only one column.
COLLECTION-VIEW –>show list of items in multiple column.
Hope it will help you.
If you choose UITableView for iPhone, make sure you have considered your iPad strategy first. If you want an iPad-specific layout, you may want that single-column layout to become a grid.
Both are depends on the requirements. Table Views also have support for a variety of editing scenarios. This support has not been implemented in the Collection View classes.
If you are converting from a Table View that relies on these methods, expect to do a little extra heavy lifting in the Collection View.
Collection View section headers can be placed anywhere within the view.
and UITableView don’t need to set buttons with tags or other things by getting selected items values.
Although it’s not required, I always use a collectionview. That way I can easily adapt how my collections are presented for differing resolutions. A plus is that it’s ready to quickly add new types of cells when refactoring in the future.
I see no point of tableviews. It’s very simple to use a collection view to represent a table. IMO.
Its totally dependent on how your data to be shown.
As mentioned by many above, if you require only single set of data and that too not complex, go for
UITableView else use
UICollectionView is customization friendly.
If you are dealing with multiple cell heights or so, then go for
Based on our need we are choosing TableView or CollectionView.
For phone contacts tableView is best option.
For photo gallery, collection view will be best option.
I had this issue in my current project. Which to use. In my case it was simple really. I needed both. I needed my view to look like UITableView and also to change its change / layout. So, UICollectionView was used. I also use UITableView everywhere I don’t need any extra customisation. Since UiTableView comes with a default layout that includes images and text – I use it for simplicity.
Based on our requirement we choose UITableView or UICollection view.
If we want to display images or items in grid type or if we need more customisability we use UICollectionview.
For listing each item with details and subdetails we use UITableView.
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.
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.