Created
May 18, 2011 02:48
-
-
Save iamcam/977906 to your computer and use it in GitHub Desktop.
Fix the second (non) tap on AQGridView item
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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) | |
**/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** "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