UICollectionViewCell中的UILabel是nill

时间:2015-03-25 11:33:54

标签: ios objective-c uilabel uicollectionviewcell

我通过xib在UICollectionViewCell上添加了一个UILabel 我已经在课堂上制作了必要的物品并将其连接起来 在cellForItemAtIndexPath方法中,我可以访问声明的UILabel,但标签始终是nill。
我可以通过编程方式向Cell添加背景颜色,但不能通过Xib添加。我也可以通过编程方式添加标签并使用它 但我不能通过xib对标签做任何事情 我已经注册了Cell类和笔尖 如果有人可以帮我解决这个问题,那就太棒了

cellforitem中的代码段 -

static NSString *cellIdentifier = @"Cell";
VideoCellCollection *cell = [self.collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
cell.backgroundColor=[UIColor whiteColor];
[cell clearData];
VideoInfo *video=[dataArray objectAtIndex:indexPath.item];
cell.lblName.text=video.strFileName; 

return cell

viewdidload中的代码

UINib *cellNib = [UINib nibWithNibName:@"VideoCellCollection" bundle:nil];

[self.collectionView registerNib:cellNib forCellWithReuseIdentifier:@"Cell"];
[self.collectionView registerClass:[VideoCellCollection class] forCellWithReuseIdentifier:@"Cell"];

提前多多感谢

1 个答案:

答案 0 :(得分:0)

尝试删除[self.collectionView registerClass:[VideoCellCollection class] forCellWithReuseIdentifier:@"Cell"];