【发布时间】:2014-12-15 08:41:51
【问题描述】:
我在 Interface Builder 中有以下 nib 设置,其中包含我的 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"];
当我尝试像这样访问我的单元格标签时:
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"dayCellDisabled" forIndexPath:indexPath];
UILabel *dayLabel = (UILabel *)[cell viewWithTag:1];
生成的dayLabel 为零,因此我无法为其分配值,并且我的视图什么也不显示。这同样适用于我的可重用标题视图及其年份和月份标签。
我在这里做错了什么?
【问题讨论】:
标签: ios objective-c uicollectionviewcell