我收到了这个错误. *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UICollectionViewCell label]: unrecognized selector sent to instance 0x1eead660'我正在使用一个nib文件作为我的单元格并尝试正确显示单元格.我猜我没有正确地返回细胞,但我不太确定.任何帮助将不胜感激.
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"Cell";
[self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"Cell"];
Cell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
NSMutableArray *data = [sections objectAtIndex:indexPath.section];
cell.label.text = [data objectAtIndex:indexPath.item];
return cell;
}
Run Code Online (Sandbox Code Playgroud)