【发布时间】:2015-05-29 01:20:09
【问题描述】:
我已经通过 xib 在 UICollectionViewCell 上添加了一个 UILabel。
我已经在课堂上制作了必要的对象并进行了适当的连接。
在 cellForItemAtIndexPath 方法中,我可以访问声明的 UILabel,但标签始终为 nill。
我可以通过编程方式向 Cell 添加背景颜色,但不能通过 Xib。我还可以通过编程方式添加标签并使用它。
但我不能通过 xib 对标签做任何事情。
我已经注册了 Cell 类和笔尖。
如果有人可以帮助我解决这个问题,那就太好了
cellforitem里面的代码sn-p-
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"];
提前非常感谢
【问题讨论】:
-
请贴一些 cellForItemAtIndexPath 的代码?
-
你可以为我们发布一些想法。还有一件事是你使用标签通过获取标签的引用?
标签: ios objective-c uilabel uicollectionviewcell