Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I animate the inner views of a collection view cell while changing it's size?
    primarykey
    data
    text
    <p>I have a collection view, and I'm going for the effect where when a cell is tapped on, it grows to take up the entire screen. To accomplish this, I'm essentially just calling <code>performBatchUpdates</code> inside <code>didSelectItemAtIndexPath</code>, and the <code>sizeForItemAtIndexPath</code> knows to return a larger size for a selected cell. This all works pretty well, the cell grows and shrinks as desired. </p> <p>The problem is inside of the cell. The collection view cell is made up of a moderately complex view hierarchy managed by constraints. I want the sub views of the cell to grow and shrink with the animating cell. Unfortunately, my subviews are snapping immediately to their new position as the cell slowly animates to it's new size. How can I ensure the content of the cell animates with the cell size?</p> <p>Here are the two relevant methods from the collection view controller:</p> <pre><code>- (CGSize) collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { if ([collectionView.indexPathsForSelectedItems containsObject:indexPath]) return CGSizeMake(collectionView.bounds.size.width - 20, collectionView.bounds.size.height - (20 + [self.topLayoutGuide length])); else return CGSizeMake(260, 100); } - (void) collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { [collectionView performBatchUpdates:nil completion:nil]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload