Instance Method


Asks the delegate for the size of the specified item.


- (NSSize)collectionView:(NSCollectionView *)collectionView layout:(NSCollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath;



The collection view object displaying the flow layout.


The layout object requesting the information.


The index path of the item.

Return Value

The size of the item. The width and height values must both be greater than 0. Items must also not exceed the available space in the collection view.


Implement this method when you want to provide the size of items in the flow layout. Your implementation can return the same size for all items or it can return different sizes for items. You can also adjust the size of items dynamically each time you update the layout. If you do not implement this method, the size of items is obtained from the properties of the flow layout object.

The size value you return from this method must allow the item to be displayed fully by the collection view. In the scrolling direction, items can be larger than the collection view because the remaining content can always be scrolled into view, but in the nonscrolling directions, items should always be smaller than the collection view itself. For example, the width of an item in a vertically scrolling collection view must not exceed the width of the collection view minus any section insets. The flow layout does not crop an item’s bounds to make it fit into the available space.

See Also