iamarnold
iamarnold

Reputation: 725

Custom UICollectionViewCell inside UICollectionView inside UITableViewCell programatically

I followed the tutorial:http://ashfurrow.com/blog/putting-a-uicollectionview-in-a-uitableviewcell/ to implement a UICollectionView inside of a UITableViewCell. How to I implement a custom UICollectionViewCell inside of the UICollectionView programmatically without using the storyboard? I just need a simple UILabel inside my UICollectionViewCell. Any help would be greatly appreciated.

Upvotes: 0

Views: 1072

Answers (1)

user3480295
user3480295

Reputation: 1048

  1. Create a custom UICollectionViewCell, named it CustomCell, and implement the method initWithFrame, where you can add UILabel to your cell.

  2. Register your custom UICollectionViewCell

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

  3. Dequeue Cell in cellForItemAtIndexPath

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

Upvotes: 2

Related Questions