Vote count:
0
Trying to resize a UICollectionViewCell when a user presses it. At the moment, the cell resizes, but the other cells do not react to it. Here is a picture of the issue:
Here is the code I am using. I have a feeling the issue is with the invalidating, but I am not sure:
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell * cellToChangeSize = [self.collectionView cellForItemAtIndexPath:indexPath]; // Avoid retain cycles
UICollectionViewCell *__weak cell = [self.collectionView cellForItemAtIndexPath:indexPath]; // Avoid retain cycles
void (^animateChangeWidth)() = ^()
{
CGRect frame = cell.frame;
frame.size = CGSizeMake(300, 100);
cell.frame = frame;
};
// Animate
[UIView transitionWithView:cellToChangeSize duration:0.1f options: UIViewAnimationOptionCurveLinear animations:animateChangeWidth completion:^(BOOL finished) {
[self.collectionView.collectionViewLayout invalidateLayout];
}];
}
asked 37 secs ago
UICollectionView not resizing correctly
Aucun commentaire:
Enregistrer un commentaire