Attaching Gestures to Cells
Send Feedback

Glossary Item Box

Topic Overview

Purpose

This topic provides a conceptual overview and uses code to demonstrate attaching gestures to cells on the IGGridView™ control.

Required background

The following table lists the topics required as a prerequisite to understanding this topic.

Topic

Purpose

Adding the Grid Framework File

This topic explains the requirements for adding the grid framework file to an Xcode project; a requirement for using the IGGridView™ control.


In this topic


Introduction

Gestures summary

Gestures recognize user screen-drawn patterns, and pass this information to your application so it can perform the action associated with your gesture. The IGGridViewCell object exposes two methods for attaching your own custom UIGestures to a cell.

  • -(void)registerGestures:(NSArray*)gestures;
  • -(void)registerTemporaryGestures:(NSArray*)gestures;

The registerGestures method, called when first creating or initializing a cell. This method hooks the gestures you assign until you call the unregisterGestures method. The IGGridViewDelegate protocol contains the following cell initialization methods.

  • -(void)gridView:(IGGridView*)gridView initializeCell:(IGGridViewCell*)cell;

As soon as a cell is out of view, the registerTemporaryGestures method automatically removes the registered gesture, which needs to reassign the temporary gesture, should the cell come back into view. The registerTemporaryGestures method can be applied in either the IGGridViewDataSource’s cellAt method or in the IGGridViewDelegate’s willDisplayCell method.

  • -(void)gridView:(IGGridView*)gridView willDisplayCell:(IGGridViewCell>*)cell forPath:(IGCellPath*)path;

Registering Gestures on a Cell – Code Example

Description

This code sample uses the IGGridViewCell object’s registerGestures method, to registers a swipe-up/swipe-down gesture and uses the IGGridViewDelegate’s initializeCell method to initialize a cell. Once registered, gestures are hooked until the unregisterGestures method is called.

Code

In Objective-C:

-(void)gridView:(IGGridView *)gridView initializeCell:(IGGridViewCell *)cell
{
    UISwipeGestureRecognizer* swipe = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(toggleDisplay)];
    swipe.direction = UISwipeGestureRecognizerDirectionUp; 
    
    UISwipeGestureRecognizer* swipe2 = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(toggleDisplay)];
    swipe2.direction = UISwipeGestureRecognizerDirectionDown; 
    
    NSMutableArray* gestures = [NSMutableArray arrayWithObjects:swipe, swipe2, nil];
    [cell registerGestures:gestures];
}

In C#:


public override void InitializeCell (IGGridView gridView, IGGridViewCell cell)
{
UISwipeGestureRecognizer swipe = new UISwipeGestureRecognizer(this.HandleSwipe);
swipe.Direction = UISwipeGestureRecognizerDirection.Up;

UISwipeGestureRecognizer swipe2 = new UISwipeGestureRecognizer(this.HandleSwipe);
swipe.Direction = UISwipeGestureRecognizerDirection.Down;

cell.RegisterGestures(new NSObject[]{swipe, swipe2});
}

Related Content

Topics

The following topics provide additional information related to this topic.

Topic

Purpose

This topic provides basic information about creating an instance of the IGGridView and displaying data to help you with getting up and running with using the control.

This section serves as an introduction to the IGGridView’s key features and functionalities.