A UIViewController maintains a reference to a UICollectionView. The controller should modify the built-in flow layout using the UICollectionViewDelegateFlowLayout.
I
My two cents for macOS Mojave - Swift
(I've fallen here searching for NSCollectionView... I do know question was about UICollectionView..)
All said above (specifying delegate implies cell size, too) is correct for macOS, too.
NOTE: If You write:
class MyViewController:
NSCollectionViewDelegate,
NSCollectionViewDataSource,
**NSCollectionViewDelegateFlowLayout**
{
the method:
func collectionView(_ collectionView: NSCollectionView,
layout collectionViewLayout: NSCollectionViewLayout,
sizeForItemAt indexPath: IndexPath) -> NSSize
will be called.
If removed, no delegate method will be called. (as class does not obey to the protocol).