Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

[ASCommonCollectionViewDelegate] -collectionView:didDeselectItemAtIndexPath not called #860

Description

@tomizimobile

I have a ASCollectionView with allowsMultipleSelection set to true. Multiple selection works fine, but neither -collectionView:shouldDeselectItemAtIndexPath nor -collectionView:didDeselectItemAtIndexPath seem to be called when trying to deselect an item. A quick change to the sample project "ASCollectionView" in ViewController.m with the following shows this behavior:

- (instancetype)init
{
  ...
  _collectionView.allowsMultipleSelection = YES;
  ...
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
  [_collectionView nodeForItemAtIndexPath:indexPath].backgroundColor = [UIColor greenColor];
}

- (BOOL)collectionView:(UICollectionView *)collectionView shouldDeselectItemAtIndexPath:(NSIndexPath *)indexPath
{
  return YES;
}

- (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath
{
  [_collectionView nodeForItemAtIndexPath:indexPath].backgroundColor = [UIColor lightGrayColor];
}

I'm using the current master (59d52ce)

Activity

  1. appleguy commented on Nov 29, 2015

    @appleguy
    Contributor

    @tomizimobile Thank you for the clear description of the issue, especially referencing the version you're using!

    I believe this is a real bug, and before noticing this issue had just filed this one: #892

    @levi, @vitalybaev - your time is very valuable and I have no explicit expectation, so don't worry if you're busy. If you do have time, this is one of the most valuable areas you could help ASDK! Next time I'll move a bit more slowly before adding a feature like selection, as it surely has some more details than we first imagined :)

  2. added this to the milestone on Nov 29, 2015
  3. changed the title [-]ASCommonCollectionViewDelegate -collectionView:didDeselectItemAtIndexPath not called[/-] [+][ASCommonCollectionViewDelegate] -collectionView:didDeselectItemAtIndexPath not called[/+] on Nov 14, 2016
  4. hannahmbanana commented on Nov 14, 2016

    @hannahmbanana
    Contributor

    I verified that this works using the collectionNode API:

    - (void)viewDidLoad
    {
      [super viewDidLoad];
    ...
    self.collectionNode.allowsMultipleSelection = YES;
    ...
    }
    
    - (void)collectionNode:(ASCollectionNode *)collectionNode didSelectItemAtIndexPath:(NSIndexPath *)indexPath
    {
      [collectionNode nodeForItemAtIndexPath:indexPath].backgroundColor = [UIColor greenColor];
    }
    
    - (BOOL)collectionNode:(ASCollectionNode *)collectionNode shouldDeselectItemAtIndexPath:(NSIndexPath *)indexPath
    {
      return YES;
    }
    
    - (void)collectionNode:(ASCollectionNode *)collectionNode didDeselectItemAtIndexPath:(nonnull NSIndexPath *)indexPath
    {
      [collectionNode nodeForItemAtIndexPath:indexPath].backgroundColor = [UIColor lightGrayColor];
    }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions