art*_*ras 2 objective-c ios uicollectionviewcell
我在Interface Builder中具有以下笔尖设置,其中包含我的viewController的主视图(带有UICollectionView)以及标头和单元格的可重用视图

我在viewDidLoad中注册可重用的视图
[self.calendarView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"dayCell"];
[self.calendarView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"dayCellDisabled"];
[self.calendarView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"monthHeader"];
Run Code Online (Sandbox Code Playgroud)
当我尝试像这样访问我的单元格标签时:
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"dayCellDisabled" forIndexPath:indexPath];
UILabel *dayLabel = (UILabel *)[cell viewWithTag:1];
Run Code Online (Sandbox Code Playgroud)
结果dayLabel为nil,因此无法为其分配值,并且视图不显示任何内容。我的可重复使用标题视图及其“年”和“月”标签也是如此。
我在这里做错了什么?
我在这里做错了什么?
几件事:
| 归档时间: |
|
| 查看次数: |
928 次 |
| 最近记录: |