Should I use tableview, collectionview, or scrollview when dealing with vertical items different from each other in XCode?

0

Good evening,

I started learning Swift a short time ago and I'm trying to develop an app in XCode. Today I found the following situation: I need to make a list of information in which it is possible to scroll down, in addition to being able to vertically expand one of the rows in the list, sending the others down, so I thought, "Ah, a tableview, obviously. .. ".

However, what happens is that all the cells in this tableview will be totally different from each other, both in content and in the position of the elements within the cell. And taking into account all the examples of tableviews I've seen so far, it seems like they're always used for standardized lists, like the list of videos you've searched for in the youtube app, for example. I started doing it for tableview and it seems to me that I'm doing a lot of code atoa, which should have an easier way to do this kind of thing.

There, I discovered that there are two potential ways of doing what I want: collection views and scroll views, which in my ignorance seem to have a smaller focus on standardized lists.

So what I want to know is which of these 3 solutions is most appropriate for my case, especially given their ease and flexibility in dealing with non-standard lists? Thankful.

    
asked by anonymous 15.04.2018 / 01:45

1 answer

0

The Collection would not solve your problem, since it has the same usability, the difference between it and a TableView basically is that, besides being able to have the horizontal scroll, it can contain columns.  The table view can have its height modified to adapt to all types of content you need using dynamic cells and its height being enforced by the use of constraints, where your code will be less coupled, creating a class for each type of cell.  And in the latter case, you can use a ScrollView, but its use is limited compared to a TableView, but you can structure the content in a totally random way.  Also another difference you need to worry about is what features a table has that a scrollview will not offer, such as selection, line deletion, among other features of each cell.


Using TableView with Dynamic Cells


Usingthe2ColumnCollectionView

The example file is in this GitHub

    
22.04.2018 / 07:17