Skip to content
This repository was archived by the owner on Oct 10, 2018. It is now read-only.

Commit 6c34496

Browse files
committed
Merge pull request #5 from joakin8/v1
Added didDeselectCellAtRow and shouldSelectCellAtRow to DRCollectionV…
2 parents 0849a18 + e6e2f40 commit 6c34496

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

DRCollectionViewTableLayout/DRCollectionViewTableLayoutManager.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,36 @@
199199
column:(NSUInteger)column
200200
indexPath:(NSIndexPath *)indexPath;
201201

202+
/**
203+
* Will be called when user deselects cell
204+
*
205+
* @param manager Collection View Table Layout Manager
206+
* @param collectionView Collection View
207+
* @param row Layout's row
208+
* @param column Layout's column
209+
* @param indexPath Collection View Cell index path
210+
*/
211+
- (void)collectionViewTableLayoutManager:(DRCollectionViewTableLayoutManager *)manager
212+
collectionView:(UICollectionView *)collectionView
213+
didDeselectCellAtRow:(NSUInteger)row
214+
column:(NSUInteger)column
215+
indexPath:(NSIndexPath *)indexPath;
216+
217+
/**
218+
* Will be called in order to decide if the cell has to be selected or not
219+
*
220+
* @param manager Collection View Table Layout Manager
221+
* @param collectionView Collection View
222+
* @param row Layout's row
223+
* @param column Layout's column
224+
* @param indexPath Collection View Cell index path
225+
*/
226+
- (BOOL)collectionViewTableLayoutManager:(DRCollectionViewTableLayoutManager *)manager
227+
collectionView:(UICollectionView *)collectionView
228+
shouldSelectItemAtRow:(NSUInteger)row
229+
column:(NSUInteger)column
230+
indexPath:(NSIndexPath *)indexPath;
231+
202232
@end
203233

204234
/**

DRCollectionViewTableLayout/DRCollectionViewTableLayoutManager.m

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,39 @@ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPa
189189
}
190190
}
191191

192+
193+
- (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath {
194+
NSUInteger row = [(DRCollectionViewTableLayout *)collectionView.collectionViewLayout rowNumberForIndexPath:indexPath];
195+
NSUInteger column = [(DRCollectionViewTableLayout *)collectionView.collectionViewLayout columnNumberForIndexPath:indexPath];
196+
197+
SEL selector = @selector(collectionViewTableLayoutManager:collectionView:didDeselectCellAtRow:column:indexPath:);
198+
199+
if ([self.delegate respondsToSelector:selector]) {
200+
201+
[self.delegate collectionViewTableLayoutManager:self
202+
collectionView:collectionView
203+
didDeselectCellAtRow:row
204+
column:column
205+
indexPath:indexPath];
206+
}
207+
}
208+
209+
- (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath {
210+
NSUInteger row = [(DRCollectionViewTableLayout *)collectionView.collectionViewLayout rowNumberForIndexPath:indexPath];
211+
NSUInteger column = [(DRCollectionViewTableLayout *)collectionView.collectionViewLayout columnNumberForIndexPath:indexPath];
212+
213+
SEL selector = @selector(collectionViewTableLayoutManager:collectionView:shouldSelectItemAtRow:column:indexPath:);
214+
215+
if ([self.delegate respondsToSelector:selector]) {
216+
217+
return [self.delegate collectionViewTableLayoutManager:self
218+
collectionView:collectionView
219+
shouldSelectItemAtRow:row
220+
column:column
221+
indexPath:indexPath];
222+
}
223+
224+
return YES;
225+
}
226+
192227
@end

0 commit comments

Comments
 (0)