ANSWERED by Starsky
I am trying to build a view with several horizontal scrollable lists populated with 12 cells in the same row. The problem is that that the cells show up "in two rows in the same row". To clarify, the row is split into two rows of 6 cells stacked over each other.
The view is a UITableView where each row is a UITableViewCell. The UITableViewCell has a UICollectionViewFlowLayout with horizontal scroll direction. The UITableViewCell contains a UICollectionView. The UICollectionView is populated with a list of UICollectionViewCell:s registered from a UINib (from a XIB file).
Everything is loaded correctly and works fine, but the UICollectionViewCell:s are stacked in two rows of 6 cells each in the horizontal scroll list which should consist of one row of 12 cells.
I can include lots of more code, but I do not know where the problem is, perhaps it has to do with dequeueReusableCell, see attached code below?
Note, I have tried to add an odd number of elements. Then the upper row is one cell longer than the lower row, like this. It looks like it wraps around two lines.
Actual
X X X X X X X
X X X X X X
Expected
X X X X X X X X X X X X X
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let item = items[indexPath.row]
if let cell = tableView.dequeueReusableCell(withIdentifier: HorizontalListTableViewCell.identifier, for: indexPath) as? HorizontalListTableViewCell {
cell.item = item
return cell
}
}
return UITableViewCell()
}
Expected results:
X X X X X X X X X X X X
X X X X X X X X X X X X
X X X X X X X X X X X X
Actual results:
X X X X X X
X X X X X X
X X X X X X
X X X X X X
X X X X X X
X X X X X X
Where X is a cell in a scrollable list.