0

각 행에 3 개의 셀이 포함 된 collectionview가 있습니다. 연속으로 3 개의 세포가 없을 때마다 세포는 중간에 정렬됩니다. 나는 그들이 왼쪽 정렬 할 싶습니다. 어떻게해야합니까?Xcode UICollectionview 셀 정렬 왼쪽

아래 이미지는 내 문제를 보여줍니다. 셀 4를 왼쪽에 어떻게 정렬합니까?

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section 
{ 
    return UIEdgeInsetsMake(0, 10, 0, 10); 
} 

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath 
{ 

    CGRect screenBound = [[UIScreen mainScreen] bounds]; 
    CGSize screenSize = screenBound.size; 
    CGFloat screenWidth = screenSize.width; 
    CGFloat screenHeight = screenSize.height; 

    return CGSizeMake(screenWidth/3-20, 80); //three cells per row 

} 

가 사전에 감사합니다

enter image description here

이 현재 코드 내가 컨트롤 크기와 세트가 있습니다.

+1

이 동작은 'UICollectionViewFlowLayout'의 표준 동작입니까? –

+0

@RoboticCat, 표준 동작에 따라 collectionview 셀은 항상 왼쪽에서 시작합니다. – Maddy

답변

0
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath 
{ 

    CGRect screenBound = [[UIScreen mainScreen] bounds] 
     float colum = 3.0; 
    float spacing = 10.0; 
    float value = floorf((Float(screenwith) - (colum - 1) * spacing)/
    colum) 

    return CGSizeMake(value, value); //three cells per row 

}