Class

NSGridView

A container that aligns views in a flexible grid of rows and columns.

Declaration

@interface NSGridView : NSView

Overview

A grid view helps you lay out content, such as photos or thumbnails, in a row-column arrangement similar to a spreadsheet. Within a grid view, an item that occupies a single row-column intersection is represented by an NSGridCell object.

Topics

Creating a Grid View

+ gridViewWithNumberOfColumns:rows:

Creates a newly allocated grid view object with the specified number of columns and rows.

+ gridViewWithViews:

Creates a newly allocated grid view object with the specified array of arrays of views.

- initWithFrame:

Creates a newly allocated grid view object with the specified frame rectangle.

- initWithCoder:

Creates a newly allocated grid view object from the coder.

Getting Information About the Grid

numberOfRows

The number of rows in the grid view.

numberOfColumns

The number of columns in the grid view.

- indexOfColumn:

Returns the index of the specified grid column.

- rowAtIndex:

Returns the grid row object at the specified index.

- columnAtIndex:

Returns the grid column object at the specified index.

- indexOfRow:

Returns the index of the specified grid row.

Adding, Removing, and Moving Rows

- addRowWithViews:

Adds an array of views to a new row.

- insertRowAtIndex:withViews:

Inserts the array of view objects into the grid view at the index.

- removeRowAtIndex:

Removes the row from the grid view at the index.

- moveRowAtIndex:toIndex:

Moves the specified row to the new row location.

Adding, Removing, and Moving Columns

- addColumnWithViews:

Adds a new column containing the array of views.

- insertColumnAtIndex:withViews:

Inserts the array of view objects at the specified index.

- removeColumnAtIndex:

Removes the column from the grid view at the specified index.

- moveColumnAtIndex:toIndex:

Moves the specified column to a new column location.

Managing Grid Spacing and Alignment

NSGridViewSizeForContent

The default value for row and column sizes.

columnSpacing

The column spacing for the grid view.

rowSpacing

The row spacing for the grid view.

rowAlignment

The row alignment for the grid view.

xPlacement

The placement of the cell within the grid column.

yPlacement

The placement of the cell within the grid row.

Creating and Merging Cells

- cellAtColumnIndex:rowIndex:

Returns the grid cell object at the specified column and row index.

- cellForView:

Returns the grid cell object that contains the given view or one of its ancestors.

- mergeCellsInHorizontalRange:verticalRange:

Expands the cell at the top-leading corner of the horizontal and vertical range to cover the entire area.

Relationships

Inherits From