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.
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
Hey steve,
I have it set up currently like this, and it seems to be working just fine... so I'm curious if you see anything wrong with this approach, because I didn't quite follow your example.
I have not noticed any issues that would indicate I need 'requireGestureRecognizerToFail'
The short and long taps seem to be recognized fine. The only slight difference from the default tap handler method the grid raises is that I don't have a will... and did... pair of methods, and I have to grab the tapped cell from the recognizer.
This was how I had it set up when I posed the initial question
I set up the gestures like this...
and then set up the handlers like this...