0

Ich habe eine UICollectionView und eine benutzerdefinierte UIcollectionViewCell.
Innerhalb dieser Zelle gibt es eine UITableView.Wie ändert man UICollectionview Zellenhöhe dynamisch?

Der Inhalt der Tabellenansicht ändert sich dynamisch, so dass die Höhe auch dynamisch geändert wird.
Ich möchte UICollectionViewCell, um seine Höhe in Bezug auf die Tabellenansicht in der Collectionviewcell zu ändern.

Wie geht das?

+0

Mögliches Duplikat von [UICollectionView-Zelle mit dynamischer Größe] (http://stackoverflow.com/questions/23760275/dynamic-size-uicollectionview-cell) – 7vikram7

Antwort

1

Verwenden Kollektion Delegierter für Größe Zelle Einstellung

Objective-C

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

     NSLog(@"SETTING SIZE FOR ITEM AT INDEX %d", indexPath.row); 

     //Calculate the height required for tableView inside the cell and set it to the cell 
     return CGSizeMake(80, 80); 
} 

Swift

func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize { 

     NSLog(@"SETTING SIZE FOR ITEM AT INDEX %d", indexPath.row); 

     //Calculate the height required for tableView inside the cell and set it to the cell 
     return CGSizeMake(80, 80); 
} 

Hoffe, dass es Ihnen hilft.