Pairs of cells in columns in a custom UICollectionView layout - ios

I'm trying to make something like this with a collection view.
| imageview |
|label| |value|
|label| |value|
So far I have been able to display two sections (the first being the image view, the second being the label), but I'm lost at how to add a second column to the second section. I've been looking around for how to do this but all I've seen are how to make the same type of cell be displayed in columns.
Should these labels and values be different sections where I create different custom cells? And should I be using UICollectionViewFlowLayout to display the two different sections side by side?

You can make the image view a supplementary view of the collection view. Here is a tutorial that can show you how to do that.

Related

UITableView cells on the same row

as I say in the title, I'd like to display two or more cells on the same row. I have every cell with a UILabel inside. The labels can have changing width depending on user's input. I'd like to fill a row with many labels as I can. Can someone give me some advice on how to do it? Thanks.
Short answer: You can't. Slightly longer answer: Use a collection view.
Table views are designed to show a single column of cells.
You can't make a table view contain multiple cells in a row.
You could probably create a view controller that had side-by-side table views inside it, but it would be awkward and hard to use, and the table views would scroll independently of each other.
If you want multiple cells on the same row, you want a collection view. A collection view is similar to, but more flexible than, a table view.
I would consider using a horizontal UIStackView to achieve what you're trying to do. Depends on how dynamic and changeable you need it to be.

Should I use a UITableView or UICollectionView to create this

I would like to create the following, but not absolutely sure which one is the best to use: UITableView or UICollectionView?
Table views only do a single vertical list of cells. If you need a grid with rows and columns then you need a collection view.
If the 3 parts of your A-G rows are separate sections of single items then you might use a table view. (Say the left column contains an image, the middle column contains a title and subheading, and the right column contains a description of the item.)

UICollectionViewFlowLayout sections as columns rather than rows

I'm trying to create a UICollectionView of two columns (of potentially different lengths) with the property that when a cell is deleted the cells below (rather than the cells to the right) move up to take its place. I have considered customising the layout using layoutAttributesForElementsInRect etc but don't want to do this if there's an easier way.
Basically all I need is the transpose of the standard FlowLayout with each section a new column instead of a new row. Any advice would be much appreciated.
It is not possible using UICollectionView without customizing the collection view layout based on your needs. UICollectionViewFlowLayout is a line breaking layout that means, it places all your cells along a line and break that line to the bounds of the collection view one by one. So you can place two cells in a row by adjusting the cell size and section insects. Even though it wont allow you adjust the cell during the deletion as your need. Obviously the adjacent cell will take place the position when deleting a cell. Can you go with two collection views side by side instead of one??

UICollectionView as a subView of a TableViewCell

I need an advice for a thing I want to implement for an iPhone application.
Actually what I want is to have the ability to dynamically populate a TableView with a specific template delivered by an engine (is it clear ? ...)
For that I want each of my TableViewCell of the TableView to be a UICollectionView.
For example :
I want to display an image, a title and a subtitle in my cell (I know I can do this by using a UITableViewCellStyleSubtitle, but when I have more complicated things to display it won't work with it).
For that, I want a UICollectionView with 2 columns and 2 rows on each column. The first item (image) will be placed on 0,0 with a 2 colSpan (to take the whole column). The second item (title) on 1,0 and the third item (subtitle) on 1,1.
I also want the collection view items to be sized correctly.
So 2 questions :
1) Is it a good way to work with a UICollectionView, or is there simpler ways ?
2) How can I specify rows and columns, along with colspan and rowspan in a UICollectionView ?
Thank you very much for your answers :)
A collection view is overkill for this. Just define a cell with custom subviews. You can resize them if required when the cell is populated. You haven't said what the most complex or simplest layout will be so I can't offer any more specific advice.

Xcode iPhone - Create a Table (NOT a Tableview) within a view

Is it possible to create a normal data table (HTML equivalent would be ".." as I would like to display some structured information within my scroll view along with text etc and also be able to style each row etc. I would require 3 cols by numerous rows basically.
You'll need to manually create the cells using UILabels. I'd suggest making a new class LabelTable that subclasses UIView. It could take column and row counts as arguments to the init selector. At init just set the frames of the UILabels to CGRectZero, then set all the text on all the cells, then in layoutSubviews actually take care of sizing the cells and aligning them correctly.

Resources