Reputation: 6795
I have the following nib setup in Interface Builder that contains my viewController's main view (with UICollectionView) and reusable views for header and cells
I register for reusable views in viewDidLoad
[self.calendarView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"dayCell"];
[self.calendarView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"dayCellDisabled"];
[self.calendarView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"monthHeader"];
When I try to access my cell label like this:
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"dayCellDisabled" forIndexPath:indexPath];
UILabel *dayLabel = (UILabel *)[cell viewWithTag:1];
the resulting dayLabel
is nil, therefore I cannot assign it a value, and my view displays nothing. The same applies to my reusable header view and its Year and Month labels.
What am I doing wrong here?
Upvotes: 2
Views: 1080
Reputation: 119242
What am I doing wrong here?
Several things:
Upvotes: 5