I've done this several dozen times with custom and standard UITableView
cells. All my outlets are connected. The UILabel
is a subview of my UICollectionViewCell
in IB. My UICollectionViewCell
object inherits the proper class in identity inspector.
How do I set UILabel
on UICollectionViewCell
?
MyCell.m
-(void)setCellName:(NSString *)cellName {
self.cellLabel.text = cellName;
}
ViewController.m
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath {
ADMCell *cell =
(ADMCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"ADMCell"
forIndexPath:indexPath];
[cell setCellName:[NSString stringWithFormat:@"%d",[indexPath row]]];
return cell;
}
Output of cell.debugDescription:
2013-05-15 22:05:40.191 ProductName[857:c07] cell.debugDescription:
<ADMCell: 0xb35c890; baseClass = UICollectionViewCell;
frame = (245 266; 70 80); layer = <CALayer: 0xb35c780>>`
try this it works for me.
cell.h file
cell.m file
// Take collectionviewCell in xib and make outlet on CollectionViewXib.
/////////////////////////////////////
now use of collection view