簡體   English   中英

在UITableViewCell內的UICollectionView內以編程方式自定義UICollectionViewCell

[英]Custom UICollectionViewCell inside UICollectionView inside UITableViewCell programatically

我遵循了該教程: http ://ashfurrow.com/blog/putting-a-uicollectionview-in-a-uitableviewcell/在UITableViewCell內部實現UICollectionView。 如何在不使用情節提要的情況下以編程方式在UICollectionView內部實現自定義UICollectionViewCell? 我只需要在UICollectionViewCell中使用一個簡單的UILabel。 任何幫助將不勝感激。

  1. 創建一個自定義UICollectionViewCell ,將其命名為CustomCell ,並實現方法initWithFrame ,您可以在其中將UILabel添加到您的單元格中。

  2. 注冊您的自定義UICollectionViewCell

    [self.collectionView registerClass:[CustomCell class] forCellWithReuseIdentifier:CollectionViewCellIdentifier];

  3. 使cellForItemAtIndexPath單元出cellForItemAtIndexPath

    CustomCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CollectionViewCellIdentifier forIndexPath:indexPath];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM