Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1935
GridView cell gestures
posted

I was looking for a way to use ...

-(IGCellPath *)gridView:(IGGridView *)gridView willSelectCellAtPath:(IGCellPath *)path

-(IGCellPath *)gridView:(IGGridView *)gridView didSelectCellAtPath:(IGCellPath *)path

... for the quick taps, where I would display an editor.

I also wanted to add a long press gesture recognizer for showing a context menu.

I did that by calling IGGridView registerGestures:


But I noticed after adding the long tap through registerGestures, the willSelectCellAtPath and didSelectCellAtPath stopped being called.  So I then had to add a short tap recognizer.


Is this all correct and best practice if I need a short and long tap to be recognized in a cell...  that I need to add them through registerGestures, and not use the willSelect... and didSelect... methods.

Thanks

Dave.

Parents
No Data
Reply
  • 40030
    Offline posted

    Hi Dave, 

    You have a few different options. 

    First, the IGGridView has a built in mechanism for handling the context menu's, if you want to display a native context menu. 

    http://help.infragistics.com/iOS/2015.2/?page=IGGridView_Enabling_Configuring_Context_Menus.html

    However, if you want to display your own context menu, you can do that as well. 

    The best place to register your custom gestures is via the following delegate method: 

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

    The IGGridViewCell uses a UITapGesture for selection. We expose that gesture off of the cell: 

    @property(nonatomic, readonly)UIGestureRecognizer* selectionGesture;

    Since the UILongPress and UITap gestures are similar, they don't normally get along. Luckily Apple exposes the following method off a gesture: requireGestureRecognizerToFail.

    https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIGestureRecognizer_Class/index.html#//apple_ref/occ/instm/UIGestureRecognizer/requireGestureRecognizerToFail:

    This basically lets you say that the one gesture is able to execute if another gesture fails. 

    Hope this helps!

    -SteveZ

     


Children