2016-06-24 4 views

Antwort

1

Haben Sie das versucht? Ändern Sie Ihre sizeForItemAtIndexPath Funktion mit meiner.

- (CGSize)collectionView:(UICollectionView *)collectionView 
      layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { 
    if (indexPath.row%3==0) { 
     return CGSizeMake(self.collectionView.frame.size.width, 80); 
    } 
    CGFloat minSpace = 10; //Set this minSpace for space that you want between two cell 
    return CGSizeMake((self.collectionView.frame.size.width - minSpace)/2, 80); 
} 

Auch Ihre cellForItemAtIndexPath, wenn die Bedingung mit sich dies ändern, wenn die Bedingung zwei verschiedene Zell zurückzukehren. Wenn Sie haben.

Hoffe, das wird Ihnen helfen.

+0

nicht funktioniert Buddy –

+0

Begrüßung durch Tableview erreichen ...... :) –

1

Ihre Zielzelle Index nach Auftrag sind 0, 1,2, 3 , 4,5 , 7,8 ...... Ihr Auftrag zur Identifikation 0, 3,6,9 ... Code für Größe für Artikel bei indexPath sollte für Abschnitte 5,5,5,5

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


    NSUInteger pos = indexPath.row; 
    if(pos%3==0) 
    { 
     return CGSizeMake(dynamicCollection.frame.size.width-10, 80); 

    } 
    else 
    { 
     return CGSizeMake(dynamicCollection.frame.size.width/2-10, 80); 
    } 

} 

In Ihrer Geschichte Bord bieten Einsatz sein. Wählen Sie die Sammlungsansicht und das Skalierungsattribut aus.

enter image description here

+0

Ich fand, wo ich falsch mache. Wie auch immer, danke. Nimm +1 dafür. –