I have a collection view with several labels inside located in one line. This collection view has to have horizontal scrolling and cell width calculated dynamically based on the label's sizes. I found the solution on how to make cell's width dynamic here: Dynamic cell width of UICollectionView depending on label width
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return (labels[indexPath.row] as NSString).size(attributes: nil)
}
But this method is only called when the class conforms to UICollectionViewDelegateFlowLayout which has vertical scrolling direction that doesn't suit me.
How can I make dynamic cell width for default layout with horizontal scrolling?