Inherits from UIView
Conforms to NSCopying
SGridEventResponder
Declared in SGridCell.h
Availability
Related samples

Overview

An SGridCell object is used to represent a cell within a ShinobiGrid and can be located within the grid via its gridCoord property. This class provides basic cell functionality such as cell selection (see SGridCell protocol). This class is ideal if you want to provide custom content that the SGridAutoCell (and subclasses) are not suited for - as instances of this class have no automatic content, they are effective containers for other UIView objects (or descendants) that you may wish to add as subviews to the cell. SGridCell’s use the reuseIdentifier property for performance reasons much in the same manner as the Cocoa framework’s UIScrollView and UITableViewCell classes. For this reason it is important to ensure you make effective use of the reuseIdentifier for each different type of cell content you wish to display in the ShinobiGrid - see the included project samples for examples of the reuseIdentifer in use.

Tasks

Initialization

Content

  •   fitSubviewsToView

    Setting this property to YES results in any added subviews having dimensions automatically applied so that they are the same size as the cell. Default value is YES for the grid and NO for the data-grid.

    property
  •   contentFrame

    A readonly frame which represents the area available for content of the cell. The gridlines take up the remaining edges of the cell.

    property

Selection

Subclassing an SGridCell.

Cell Location

  •   gridCoord

    This property represents the coordinates of the cell and uniquely identifies it within its parent grid.

    property

Properties

contentFrame

A readonly frame which represents the area available for content of the cell. The gridlines take up the remaining edges of the cell.

@property (nonatomic, readonly) CGRect contentFrame

Declared In

SGridCell.h

fitSubviewsToView

Setting this property to YES results in any added subviews having dimensions automatically applied so that they are the same size as the cell. Default value is YES for the grid and NO for the data-grid.

@property (nonatomic, assign) BOOL fitSubviewsToView

Declared In

SGridCell.h

gridCoord

This property represents the coordinates of the cell and uniquely identifies it within its parent grid.

@property (nonatomic, retain, readonly) SGridCoord *gridCoord

Discussion

The notation {colIndex, row}, is sometimes used to refer to a gridCoord object within this documentation.

Declared In

SGridCell.h

reuseIdentifier

A string used to identify a cell that is reusable. (read-only)

@property (nonatomic, readonly) NSString *reuseIdentifier

Discussion

The reuse identifier is associated with a SGridCell object that the ShinobiGrid’s data source creates with the intent to reuse it as the basis (for performance reasons) for multiple cells of a ShinobiGrid object. It is assigned to the cell object in initWithReuseIdentifier: and cannot be changed thereafter. A ShinobiGrid object maintains a collection of the currently reusable cells, each with its own reuse identifier, and makes them available to the data source in the dequeueReusableCellWithIdentifier: method.

Declared In

SGridCell.h

selected

A boolean that indicates if this cell is selected or not.

@property (nonatomic, assign, readonly) BOOL selected

Return Value

selected YES if this cell is selected. NO otherwise.

Declared In

SGridCell.h

selectedColor

The color that the cell will change to when selected.

@property (nonatomic, retain) UIColor *selectedColor

Discussion

Seting this property to nil will result in a selection color that is identical to the cell’s final background color.

Warning: Important Deprecated for versions after 1.1.2. Use selectedStyle (inherited from the SGridCell protocol) instead.

Declared In

SGridCell.h

selectedStyle

The style that will be applied to the cell when selected.

@property (nonatomic, retain) SGridCellStyle *selectedStyle

Declared In

SGridCell.h

Instance Methods

applyStyle:

This method is called in order to style each cell as the grid is preparing to display.

- (void)applyStyle:(SGridCellStyle *)style

Discussion

If you create your own cell subclass you may want to override this method to ensure that the style object is properly used in the styling of the cell. For example the SGridAutoCell implementation ensures that text alignment is properly applied to the cell

Declared In

SGridCell.h

initWithReuseIdentifier:

Initializes a cell with a reuse identifier and returns it to the caller.

- (id)initWithReuseIdentifier:(NSString *)identifier

Discussion

Warning: Important This method must be used to initialize a cell - using init or initWithFrame is not permitted.

When subclassing a cell for use in a ShinobiDataGrid, ensure that you have overridden this constructor, as this is the method which the DataGrid will call when instantiating cells.

Declared In

SGridCell.h

resetForReuse

This method is called before a cell is returned from the pool that it has been stored in. Any state that may need to be reset prior to it being retrieved from [ShinobiGrid dequeueReusableCellWithIdentifier:] can be done inside this method.

- (void)resetForReuse

Discussion

Warning: Important This method is a potential performance hotspot as it is called every time a cell is retrieved as a result of a call to the data source method. For this reason you should only override this method to reset a property of this cell if changing said property within the datasource method is not applicable.

Declared In

SGridCell.h

setSelected:animated:

Set this cell as being selected or deselected.

- (void)setSelected:(BOOL)isSelected animated:(BOOL)animated

Discussion

Warning: Important Note that programmatic cell selection ignores the grid’s selectionMode, meaning that there will be no automatic deselection in any circumstances.

@parameter isSelected YES if the cell should be set as selected. @parameter animated YES if this cell’s selection change should be animated.

Declared In

SGridCell.h