Daumantas Versockas
Daumantas Versockas

Reputation: 777

iOS UICollection View layout doesn't work

I have a problem with iOS UICollectionView.

I have a UICollectionView with a layout:

UICollectionViewFlowLayout *collectionViewFlowLayout = [[UICollectionViewFlowLayout alloc] init];

collectionViewFlowLayout.itemSize = CGSizeMake(COLLECTION_VIEW_CELL_WIDTH, COLLECTION_VIEW_CELL_HEIGHT);
collectionViewFlowLayout.minimumLineSpacing = 3.0f;

My UICollectionView frame is frame = (0 ,45, 769,307);

Also, I have a custom UICollectionViewCell with frame frame = (0 ,0, 190, 100)

190 * 4 = 760. That means, that 4 cells should fit into my collection view width. But there is only 3 of them...

Where is my problem?

Upvotes: 0

Views: 200

Answers (1)

Eduardo Iglesias
Eduardo Iglesias

Reputation: 1066

you can try this delegate

#pragma mark collection view cell paddings
- (UIEdgeInsets)collectionView:(UICollectionView*)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
    return UIEdgeInsetsMake(0, 0, 0, 0); // top, left, bottom, right
}

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {

    return 0.0;
}

Upvotes: 1

Related Questions