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

Commit

Permalink
Merge pull request #5 from joakin8/v1
Browse files Browse the repository at this point in the history
Added didDeselectCellAtRow and shouldSelectCellAtRow to DRCollectionV…
  • Loading branch information
darrarski committed Jul 28, 2015
2 parents 0849a18 + e6e2f40 commit 6c34496
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
30 changes: 30 additions & 0 deletions DRCollectionViewTableLayout/DRCollectionViewTableLayoutManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,36 @@
column:(NSUInteger)column
indexPath:(NSIndexPath *)indexPath;

/**
* Will be called when user deselects cell
*
* @param manager Collection View Table Layout Manager
* @param collectionView Collection View
* @param row Layout's row
* @param column Layout's column
* @param indexPath Collection View Cell index path
*/
- (void)collectionViewTableLayoutManager:(DRCollectionViewTableLayoutManager *)manager
collectionView:(UICollectionView *)collectionView
didDeselectCellAtRow:(NSUInteger)row
column:(NSUInteger)column
indexPath:(NSIndexPath *)indexPath;

/**
* Will be called in order to decide if the cell has to be selected or not
*
* @param manager Collection View Table Layout Manager
* @param collectionView Collection View
* @param row Layout's row
* @param column Layout's column
* @param indexPath Collection View Cell index path
*/
- (BOOL)collectionViewTableLayoutManager:(DRCollectionViewTableLayoutManager *)manager
collectionView:(UICollectionView *)collectionView
shouldSelectItemAtRow:(NSUInteger)row
column:(NSUInteger)column
indexPath:(NSIndexPath *)indexPath;

@end

/**
Expand Down
35 changes: 35 additions & 0 deletions DRCollectionViewTableLayout/DRCollectionViewTableLayoutManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,39 @@ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPa
}
}


- (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger row = [(DRCollectionViewTableLayout *)collectionView.collectionViewLayout rowNumberForIndexPath:indexPath];
NSUInteger column = [(DRCollectionViewTableLayout *)collectionView.collectionViewLayout columnNumberForIndexPath:indexPath];

SEL selector = @selector(collectionViewTableLayoutManager:collectionView:didDeselectCellAtRow:column:indexPath:);

if ([self.delegate respondsToSelector:selector]) {

[self.delegate collectionViewTableLayoutManager:self
collectionView:collectionView
didDeselectCellAtRow:row
column:column
indexPath:indexPath];
}
}

- (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger row = [(DRCollectionViewTableLayout *)collectionView.collectionViewLayout rowNumberForIndexPath:indexPath];
NSUInteger column = [(DRCollectionViewTableLayout *)collectionView.collectionViewLayout columnNumberForIndexPath:indexPath];

SEL selector = @selector(collectionViewTableLayoutManager:collectionView:shouldSelectItemAtRow:column:indexPath:);

if ([self.delegate respondsToSelector:selector]) {

return [self.delegate collectionViewTableLayoutManager:self
collectionView:collectionView
shouldSelectItemAtRow:row
column:column
indexPath:indexPath];
}

return YES;
}

@end

0 comments on commit 6c34496

Please sign in to comment.