IGGridViewCellBase Class Reference

Inherits from UIView
Conforms to UIGestureRecognizerDelegate
Declared in IGGridViewCell.h

Overview

An IGGridViewCellBase is the base class used for all cells in the IGGridView. It’s a visual that maps to a coordinate system (IGCellPath) of Section, Row and Column.

The cells of the IGGridView are meant to be inherited and customized. To do this, you simply derive from the appropriate cell. For example, for standard data cells, you should derive from IGGridViewCell. @interface ButtonCell : IGGridViewCell { UIButton* _button; } @end

Then initialize the views you want to display in the cell and add them to them as subviews when the cell is intialized. -(id)init { self = [super init]; if(self) { button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button setTitle:@“Click Me” forState:UIControlStateNormal]; [self.view addSubview:button]; } return self; }

Then override the setupSize method. You can use this method to set the frame of your subviews. -(void)setupSize:(CGSize)size { _button.frame = CGRectMake(0, 0, size.width, size.height); }

If you need to do setup or clean when the cell is added to the grid view, or removed from the grid view, you can override the cell’s cellAttached and celDetached methods.

-(void)cellAttached { [_button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside]; }

-(void)cellDetached { [_button removeTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside]; }

All cells also support the use of custom gestures. For example if you wanted to add a double tap gesture to a cell, you would first need to decide if you wanted the gesture added to every cell, or a specific cell. If you wanted it on a specific cell, you would use the registerTemporaryGestures: selector, as it would be removed as soon as the cell was out of view. However, if you wanted it on every cell, then you can use the registerGestures: selector. Once you’ve decided on what cell you want to apply a gesture, you can simply create your gestures and pass them in as an array to the the formerly mention selectors. After that, the cell will take care of the rest and attach your gestures for you.

Initializing a Cell object

– initWithReuseIdentifier:

Initializes and returns a cell object with the specified reuse identifier.

- (instancetype)initWithReuseIdentifier:(NSString *)identifier

Parameters

identifier

A string which specifies the identifier used for recycling.

Return Value

Returns an initialized IGGridViewCellBase object or nil if the object could not be successfully initialized.

Discussion

You must specify the reuse identifier of a cell when you create it and you cannot thereafter modify it.

Declared In

IGGridViewCell.h

  reuseIdentifier

A string which is used by the grid view to determine reuse via an internal recycling engine (readonly)

@property (nonatomic, readonly, copy) NSString *reuseIdentifier

Discussion

This property can only be set when the cell is initialized via the initWithReuseIdentifier: selector.

Declared In

IGGridViewCell.h

Custom Gestures

– registerGestures:

Applies UIGestureRecognizer objects to the cell

- (void)registerGestures:(NSArray<__kindofUIGestureRecognizer*> *)gestures

Parameters

gestures

An array of UIGestureRecognizer objects.

Discussion

Takes the array of gestures and applies them to the cell. The gestures will remain applied to the cell until they unregisterGestures selector is called. This method should be used when the cell is first created or initialized.

Declared In

IGGridViewCell.h

– unregisterGestures

Unregisters all gestures specified by the registerGestures: selector

- (void)unregisterGestures

Declared In

IGGridViewCell.h

– registerTemporaryGestures:

Applies UIGestureRecognizer objects to the cell

- (void)registerTemporaryGestures:(NSArray<__kindofUIGestureRecognizer*> *)gestures

Parameters

gestures

An array of UIGestureRecognizer objects.

Discussion

Takes the array of gestures and applies them to the cell. The gestures will remain applied to the cell while it’s in view. As soon as it’s out of view the gestures will be removed. You can then add gestures again when the cell comes back in view.

Declared In

IGGridViewCell.h

Protected Members

  contentInset

The inset of the content of a cell.

@property (nonatomic, assign) UIEdgeInsets contentInset

Discussion

This property should not be set directly, as the grid view will set this property based on it’s cellContentInset property.

Declared In

IGGridViewCell.h

– setupSize:

Tells the cell to setup the size of it’s content

- (void)setupSize:(CGSize)size

Parameters

size

The size of the cell view.

Discussion

This method should not be called directly. It’s for use in a derived class, and should be used for setting up and laying out the frames of the contents of the cell.

Declared In

IGGridViewCell.h

– cellDetached

Notifies the cell, that it is currently not being used by the grid view

- (void)cellDetached

Discussion

This method should not be called directly. It’s for use in a derived class to do any cleanup that might be neccessary when the cell is not currently being used.

Declared In

IGGridViewCell.h

– cellAttached

Notifies the cell that the grid view has just started using it.

- (void)cellAttached

Discussion

This method should not be called directly. It’s for use in a derived class to setup anything that is neccessary for it to display its content

Declared In

IGGridViewCell.h

– cellLocationInViewportChanged:

Notifies the cell that its location within the viewport of the grid has changed.

- (void)cellLocationInViewportChanged:(CGPoint)location

Parameters

location

A CGPoint where x represents the horizontal location of the center of the cell from 0 - 1. Where zero is the left edge of the viewport and 1 is the right edge of the viewport. Likewise, y represents the vertical location of the center of the cell from 0 - 1. Where zero is the top edge of the viewport and 1 is the bottom edge of the viewport.

Discussion

This method should not be called directly. It’s for use in a derived class to setup anything that is neccessary for it to adjust its content.

Declared In

IGGridViewCell.h

  path

The path of the cell that this IGGridViewCellBase represents.

@property (nonatomic, readonly) IGCellPath *path

Declared In

IGGridViewCell.h

  gridView

The IGGridView that is curently displaying this cell.

@property (nonatomic, readonly) IGGridView *gridView

Declared In

IGGridViewCell.h