LXReorderableCollectionViewFlowLayout icon indicating copy to clipboard operation
LXReorderableCollectionViewFlowLayout copied to clipboard

[collectionView cellForItemAtIndexPath:indexPath] cell animates at wrong location

Open ChrisKlingler opened this issue 11 years ago • 0 comments

I have a classic UICollectionView inside of a viewController that uses a LXReorderableCollectionViewFlowLayout for reordering. The reordering works great and the underlying arrays change accordingly so the cells all show up in the right locations, but I'm having an issue where a subview of the cells is supposed to animate after being selected on didSelectItemAtIndexPath, using NSLog I can tell that the selection is showing the right indexPath as being selected but a totally different cell then the one at the indexPath is animating with the following:

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{

UICollectionViewCell *cell = (UICollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath]; //animate press

    NSLog(@"indexPath cell is %@", [UICollectionView indexPathForCell:cell]); // returns the correct indexPath
    [UIView animateWithDuration:0.1f delay:0.0f options:UIViewAnimationOptionCurveEaseIn animations:^{
        cell.BackgroundView.alpha = 1.0f; //animates the wrong cell (not at indexPath reported by NSLog above)
    } completion:^(BOOL finished) {
        [UIView animateWithDuration:0.2f delay:0.0f options:UIViewAnimationOptionCurveEaseIn animations:^{
            cell.BackgroundView.alpha = 0.0f;
        } completion:^(BOOL finished) {

        }];
    }];

Here is the code from where I set up the collectionView

LXReorderableCollectionViewFlowLayout *flowLayout = [[LXReorderableCollectionViewFlowLayout alloc] init]; JobStencilLegendsCollection = [[UICollectionView alloc] initWithFrame:CGRectMake(15.0f, 190.0f, 300.0f, 300.0f) collectionViewLayout:flowLayout]; JobStencilLegendsCollection.delegate = self; JobStencilLegendsCollection.dataSource = self;

I have not changed the code for LXReorderableCollectionViewFlowLayout at all. Any ideas how the inclusion of this layout could affect which cell animates?

ChrisKlingler avatar Apr 25 '14 23:04 ChrisKlingler