Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set text in uicollectionviewcell

I have created a UIcollectionView and an array with some strings @[@"Item One", "Item Two", @"Item Three"];

In Tableview I would do this:

NSString *object = self.titlesArray[indexPath.row];
cell.textLabel.text = object;

But I can really not figure out how to do this for Items in UIcollectionView.

like image 529
M. El-Set Avatar asked Nov 21 '14 10:11

M. El-Set


2 Answers

UICollectionViewCell doesn’t have a default cell style. You have to create a custom UICollectionViewCell and add a UILabel inside.

like image 166
roborg Avatar answered Sep 27 '22 20:09

roborg


UICollectionViewCell does not have default textLabel as UITableviewCell has, you have to create custom UICollectionViewCell as per your need.

You can look at this tutorial how to create custom collection view cell.

like image 38
Yuvrajsinh Avatar answered Sep 27 '22 22:09

Yuvrajsinh