繁体   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