0
votes

I currently have a UICollectionView that is 2 columns of UICollectionViewCells, and I am wondering if someone has determined how to make a cell expands to the full width of the screen and make the others move down. I have attempted to mess with the cell's frame size and the rows, but nothing seems to behave properly at all. Any ideas?

2

2 Answers

1
votes

Does something like this work for you:

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    self.path = indexPath;
    [self.collectionView reloadData];
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    if ([indexPath isEqual:self.path]) {
        return CGSizeMake(320, 150);
    }else{
        return CGSizeMake(150, 150);
    }
}
0
votes

You need two UICollectionViewLayouts. Change your itemSize on the second UICollectionViewLayout. Then you can call setCollectionViewLayout:animated which will animate the change between the two collection view layouts.