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

Overview

An SDataGridCell object is used to represent a cell within a ShinobiDataGrid and can be located within the grid via its coordinate property. This class provides basic cell functionality such as cell selection (see SDataGridCell protocol). This class is ideal if you want to provide custom content that the SDataGridTextCell (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.

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.

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

SDataGridCell.h

coordinate

This property uniquely identifies this cell within its parent grid.

@property (nonatomic, assign, readonly) SDataGridCoord *coordinate

Declared In

SDataGridCell.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

SDataGridCell.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

SDataGridCell.h

selectedStyle

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

@property (nonatomic, retain) SDataGridCellStyle *selectedStyle

Declared In

SDataGridCell.h

Instance Methods

applyStyle:

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

- (void)applyStyle:(SDataGridCellStyle *)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

SDataGridCell.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

SDataGridCell.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

SDataGridCell.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

SDataGridCell.h