0

私はUICollectionViewとカスタムUIcollectionViewCellを持っています。
そのセルの内部には、1つがあります。UITableViewUICollectionviewのセルの高さを動的に変更するにはどうすればよいですか?

テーブルビューの内容が動的に変化するため、高さも動的に変化します。
UICollectionViewCellにCollectionviewcell内のテーブルビューとの高さを変更します。

どうすればよいですか?

+0

[Dynamic size UICollectionView cell]の可能な複製(http://stackoverflow.com/questions/23760275/dynamic-size-uicollectionview-cell) – 7vikram7

答えて

1

セルのサイズを設定するための使用collectionViewのデリゲート、

の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); 
} 

スウィフト

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); 
} 

それはあなたのお役に立てば幸いです。

関連する問題