diff --git a/CHANGELOG.md b/CHANGELOG.md index a23b27f3..e5a1c28c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ The changelog for `IGListKit`. Also see the [releases](https://github.com/instag ### Enhancements +- Added `shouldSelectItemAtIndex:` to `IGListSectionController` . [dirtmelon](https://github.com/dirtmelon) + - Introduce `IGListSwiftKit`, with Swift refinements for `dequeueReusableCellOfClass` methods. [Koen Punt](https://github.com/koenpunt) [(#1388)](https://github.com/Instagram/IGListKit/pull/1388). - Added `APPLICATION_EXTENSION_API_ONLY` support for `IGListDiffKit` [Peter Meyers](https://github.com/pm-dev) [(#1422)](https://github.com/Instagram/IGListKit/pull/1422) diff --git a/Source/IGListKit/IGListSectionController.h b/Source/IGListKit/IGListSectionController.h index 446346ad..10c16d84 100644 --- a/Source/IGListKit/IGListSectionController.h +++ b/Source/IGListKit/IGListSectionController.h @@ -75,6 +75,15 @@ NS_SWIFT_NAME(ListSectionController) */ - (void)didUpdateToObject:(id)object; +/** + Asks the section controller if the cell at the specified index path should be selected + + @param index The index of cell to be selected. + + @note The default implementation returns YES. **Calling super is not required.** + */ +- (BOOL)shouldSelectItemAtIndex:(NSInteger)index; + /** Tells the section controller that the cell at the specified index path was selected. diff --git a/Source/IGListKit/IGListSectionController.m b/Source/IGListKit/IGListSectionController.m index 24e698e7..5105d1b4 100644 --- a/Source/IGListKit/IGListSectionController.m +++ b/Source/IGListKit/IGListSectionController.m @@ -80,6 +80,10 @@ void IGListSectionControllerPopThread(void) { - (void)didUpdateToObject:(id)object {} +- (BOOL)shouldSelectItemAtIndex:(NSInteger)index { + return YES; +} + - (void)didSelectItemAtIndex:(NSInteger)index {} - (void)didDeselectItemAtIndex:(NSInteger)index {} diff --git a/Source/IGListKit/Internal/IGListAdapter+UICollectionView.m b/Source/IGListKit/Internal/IGListAdapter+UICollectionView.m index d44ce64c..7febef8d 100644 --- a/Source/IGListKit/Internal/IGListAdapter+UICollectionView.m +++ b/Source/IGListKit/Internal/IGListAdapter+UICollectionView.m @@ -118,6 +118,11 @@ #pragma mark - UICollectionViewDelegate +- (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath { + IGListSectionController * sectionController = [self sectionControllerForSection:indexPath.section]; + return [sectionController shouldSelectItemAtIndex:indexPath.item]; +} + - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { // forward this method to the delegate b/c this implementation will steal the message from the proxy id collectionViewDelegate = self.collectionViewDelegate;