Instance Method

frameForItemAtIndex:withNumberOfItems:

Returns the frame of an item based on the number of items in the collection view.

Declaration

- (NSRect)frameForItemAtIndex:(NSUInteger)index withNumberOfItems:(NSUInteger)numberOfItems;

Parameters

index

The index of the item in the collection view.

numberOfItems

The targeted number of items in the collection view. Use this parameter to specify the number of items you intend to have in the collection view, if that number is different than the actual number of items.

Return Value

The frame rectangle that reflects where the collection view would place the item.

Discussion

Using the value in the numberOfItems parameter, this method calculates the frame rectangle of the item at the specified index in the collection view.

When the collection view is a drag destination, use this method (instead of the content method) to get the frame of items. Drag operations can change the number of items, which affects the layout of the item views.

See Also

Legacy Collection View Support

itemPrototype

The receiver’s collection view item prototype.

Deprecated
- newItemForRepresentedObject:

Returns the collection view item that is used for the specified object.

Deprecated
selectionIndexes

The indexes of the currently selected items.

maxNumberOfRows

The maximum number of rows that the collection view displays.

Deprecated
maxNumberOfColumns

The maximum number of columns that the collection view displays.

Deprecated
minItemSize

The minimum size (in points) of items in the collection view grid.

Deprecated
maxItemSize

The maximum size (in points) of items in the collection view grid.

Deprecated
- itemAtIndex:

Returns the collection view item for the represented object at the specified index.

- frameForItemAtIndex:

Returns the frame of the collection view item at the specified index.

- draggingImageForItemsAtIndexes:withEvent:offset:

This method computes and returns an image to use for dragging.