Skip to content

Instantly share code, notes, and snippets.

@iamcam
Created May 18, 2011 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamcam/977906 to your computer and use it in GitHub Desktop.
Save iamcam/977906 to your computer and use it in GitHub Desktop.
Fix the second (non) tap on AQGridView item
- (void) _userSelectItemAtIndex: (UserSelectItemIndexParams*) params
{
NSUInteger index = params.indexNum;
NSUInteger numFingersCount = params.numFingers;
[self unhighlightItemAtIndex: index animated: NO];
if ( ([[self cellForItemAtIndex: index] isSelected]) && (self.requiresSelection == NO) ){
[self _deselectItemAtIndex: index animated: NO notifyDelegate: YES];
// [self _selectItemAtIndex: index animated: NO scrollPosition: AQGridViewScrollPositionNone notifyDelegate: YES
// numFingersTouch: numFingersCount];
NSLog(@"YES");
}
else{ NSLog(@"NO");
[self _selectItemAtIndex: index animated: NO scrollPosition: AQGridViewScrollPositionNone notifyDelegate: YES
numFingersTouch: numFingersCount];
}
_pendingSelectionIndex = NSNotFound;
}
/**
When clicking the same cell multiple times in a row, NSLog prints alternating YES/NO/... messages and the cell only gets selected in the view (eg to open another VC)
**/
/** "Fixed" Method **/
- (void) _userSelectItemAtIndex: (UserSelectItemIndexParams*) params
{
NSUInteger index = params.indexNum;
NSUInteger numFingersCount = params.numFingers;
[self unhighlightItemAtIndex: index animated: NO];
if ( ([[self cellForItemAtIndex: index] isSelected]) /** && (self.requiresSelection == NO)**/ ){
[self _deselectItemAtIndex: index animated: NO notifyDelegate: YES];
[self _selectItemAtIndex: index animated: NO scrollPosition: AQGridViewScrollPositionNone notifyDelegate: YES
numFingersTouch: numFingersCount];
NSLog(@"YES");
}
else{ NSLog(@"NO");
[self _selectItemAtIndex: index animated: NO scrollPosition: AQGridViewScrollPositionNone notifyDelegate: YES
numFingersTouch: numFingersCount];
}
_pendingSelectionIndex = NSNotFound;
}
/**
Performing the deselect/select on the cell allows us to tap once to select the cell like the standard tableview didSelect... method
**/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment