UICollectionView应用程序崩溃,UICollectionViewCell不符合键值

时间:2013-06-23 04:45:07

标签: ios uicollectionview

我开始用UICollectionView创建一个项目。我将UICollectionViewController拖到故事板上,并在检查器中正确识别它。然后我将UITableViewCell和UILabel拖入其中。我使用UILabel属性创建了MyCell并将其连接到插座。检查员也可以正确识别细胞。

但是当我运行应用程序时,它崩溃了:

[setValue:forUndefinedKey:]:此类与密钥cellLabel不符合密钥值编码

其中cellLabel是MyCell的UILabel属性。这是我的cellForItemAtIndexPath:

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    MyCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
    NSManagedObject *object = [self.fetchedResultsController objectAtIndexPath:indexPath];
    cell.cellLabel.text = [[object valueForKey:@"timeStamp"] description];
    return cell;
}

Cell是Attributes Inspector中的标识符。

可能出现什么问题?

2 个答案:

答案 0 :(得分:1)

如果您将自定义单元格的CustomClass属性设置为MyClass,请检入Interface-Builder。

答案 1 :(得分:0)

这是一个XCode5错误。由于某种原因,它没有关联MyCell.m类文件的目标成员资格。