UICollectionView sets 3 cells per row to fit screen width

The iPhone's screen is 320 pt wide as we know it. I need to add 3 cells to a row and my UICollections width is also 320.

But the problem is here:

if we use, for example, 106pt for the cell width, then we have 2 pt of space between the cells. And this is correct, because viewing the collection automatically places the cells. If I use 107 pt for the cell width, then the collection view only shows 2 cells per row, which is also correct, but not for my purposes.

From coherences, I can check, for example, every 2 cells in the code and set 108 pt instead of 106 pt for that cell, but maybe there is another good solution with a constraint, for example?

+3


source to share





All Articles