Skip to content

Commit 2a86b77

Browse files
catlanAlanQuatermain
authored andcommitted
add indexForCell
1 parent 7626d30 commit 2a86b77

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

Classes/AQGridView.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ extern NSString * const AQGridViewSelectionDidChangeNotification;
172172
- (CGRect) rectForItemAtIndex: (NSUInteger) index;
173173
- (AQGridViewCell *) cellForItemAtIndex: (NSUInteger) index;
174174
- (NSUInteger) indexForItemAtPoint: (CGPoint) point;
175+
- (NSUInteger) indexForCell: (AQGridViewCell *) cell;
175176
- (AQGridViewCell *) cellForItemAtPoint: (CGPoint) point;
176177

177178
- (NSArray *) visibleCells;

Classes/AQGridView.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,15 @@ - (NSUInteger) indexForItemAtPoint: (CGPoint) point
615615
return ( [_gridData itemIndexForPoint: point] );
616616
}
617617

618+
- (NSUInteger) indexForCell: (AQGridViewCell *) cell
619+
{
620+
NSUInteger index = [_visibleCells indexOfObject:cell];
621+
if (index == NSNotFound)
622+
return NSNotFound;
623+
624+
return _visibleIndices.location + index;
625+
}
626+
618627
- (AQGridViewCell *) cellForItemAtPoint: (CGPoint) point
619628
{
620629
return ( [self cellForItemAtIndex: [_gridData itemIndexForPoint: point]] );

0 commit comments

Comments
 (0)