以编程方式在 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。任何帮助将不胜感激。
创建自定义 UICollectionViewCell
,将其命名为 CustomCell
,并实现方法 initWithFrame
,您可以在其中将 UILabel
添加到您的单元格。
注册您的自定义 UICollectionViewCell
[self.collectionView registerClass:[CustomCell class] forCellWithReuseIdentifier:CollectionViewCellIdentifier];
出列 cellForItemAtIndexPath
中的单元格
CustomCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CollectionViewCellIdentifier forIndexPath:indexPath];
我按照教程:http://ashfurrow.com/blog/putting-a-uicollectionview-in-a-uitableviewcell/ 在 UITableViewCell 中实现了 UICollectionView。如何在不使用故事板的情况下以编程方式在 UICollectionView 内部实现自定义 UICollectionViewCell?我的 UICollectionViewCell 中只需要一个简单的 UILabel。任何帮助将不胜感激。
创建自定义
UICollectionViewCell
,将其命名为CustomCell
,并实现方法initWithFrame
,您可以在其中将UILabel
添加到您的单元格。注册您的自定义
UICollectionViewCell
[self.collectionView registerClass:[CustomCell class] forCellWithReuseIdentifier:CollectionViewCellIdentifier];
出列
中的单元格cellForItemAtIndexPath
CustomCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CollectionViewCellIdentifier forIndexPath:indexPath];