From 1f740e9165e939d369f18f22a8a8befb3eed19c5 Mon Sep 17 00:00:00 2001 From: Dimitri Bouniol Date: Wed, 21 Jan 2015 09:38:20 -0800 Subject: [PATCH] Added a way to fetch MDSpreadViewCell from index path pair --- Classes/MDSpreadView.h | 2 +- Classes/MDSpreadView.m | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Classes/MDSpreadView.h b/Classes/MDSpreadView.h index c75a441..02a0c18 100644 --- a/Classes/MDSpreadView.h +++ b/Classes/MDSpreadView.h @@ -282,7 +282,7 @@ extern NSString *MDSpreadViewSelectionDidChangeNotification __attribute__((unava //- (MDIndexPath *)indexPathForCell:(UITableViewCell *)cell; // returns nil if cell is not visible //- (NSArray *)indexPathsForRowsInRect:(CGRect)rect; // returns nil if rect not valid -//- (UITableViewCell *)cellForRowAtIndexPath:(MDIndexPath *)indexPath; // returns nil if cell is not visible or index path is out of range +- (MDSpreadViewCell *)cellForRowAtIndexPath:(MDIndexPath *)rowPath forColumnAtIndexPath:(MDIndexPath *)columnPath; // returns nil if cell is not visible or index path is out of range //- (NSArray *)visibleCells; //- (NSArray *)indexPathsForVisibleRows; diff --git a/Classes/MDSpreadView.m b/Classes/MDSpreadView.m index 7868e30..9a41cc1 100644 --- a/Classes/MDSpreadView.m +++ b/Classes/MDSpreadView.m @@ -3321,6 +3321,22 @@ - (void)_clearAllCells } } +- (MDSpreadViewCell *)cellForRowAtIndexPath:(MDIndexPath *)rowPath forColumnAtIndexPath:(MDIndexPath *)columnPath +{ + NSMutableSet *allVisibleCells = [NSMutableSet setWithArray:mapForContent.allCells]; + [allVisibleCells addObjectsFromArray:mapForColumnHeaders.allCells]; + [allVisibleCells addObjectsFromArray:mapForRowHeaders.allCells]; + [allVisibleCells addObjectsFromArray:mapForCornerHeaders.allCells]; + + for (MDSpreadViewCell *cell in allVisibleCells) { + if ([cell._rowPath isEqualToIndexPath:rowPath] && [cell._columnPath isEqualToIndexPath:columnPath]) { + return cell; + } + } + + return nil; +} + #pragma mark - Fetchers #pragma mark — Sizes