简体   繁体   English

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

[英]UICollectionView app crashes with UICollectionViewCell not key value compliant

I started creating a project with UICollectionView. 我开始使用UICollectionView创建一个项目。 I dragged a UICollectionViewController to storyboard and made properly identified it in the inspector. 我将UICollectionViewController拖到情节提要中,并在检查器中正确识别了它。 Then I dragged in a UITableViewCell and a UILabel into it. 然后,我将一个UITableViewCell和一个UILabel拖入其中。 I created MyCell with a UILabel property and connected it to the outlet. 我使用UILabel属性创建了MyCell并将其连接到插座。 The cell is properly identified in the inspector as well. 单元也可以在检查器中正确识别。

But when I run the app it crashed with the: 但是,当我运行该应用程序时,它崩溃了:

[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key cellLabel [setValue:forUndefinedKey:]:此类与键cellLabel的键值编码不兼容

where cellLabel is the UILabel property of MyCell. 其中cellLabel是MyCell的UILabel属性。 Here is my cellForItemAtIndexPath: 这是我的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;
}

And Cell is the identifier in the Attributes Inspector. 而Cell是“属性”检查器中的标识符。

What could be wrong? 有什么事吗

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

It was an XCode5 error. 这是XCode5错误。 It didnt associate the target membership for the MyCell.m class file for some reason. 由于某种原因,它没有关联MyCell.m类文件的目标成员身份。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 应用程序崩溃,因为 - “类不是键的键值编码兼容” - App crashes because - "Class is not key value coding-compliant for the key" 带有 UICollectionView 的 xib - 不符合键值编码 - xib with UICollectionView - not key value coding compliant 应用程序在单击时崩溃并显示以下消息:“该类与键 postReplyButton 的键值编码不兼容。” - App crashes at click with message: 'this class is not key value coding-compliant for the key postReplyButton.' NSManagedObject密钥存在于实体描述中,但是当尝试访问它时,应用程序崩溃,并显示“此类不符合键值编码标准” - NSManagedObject key exists in the entity description but when trying to access it the app crashes with “this class is not key value coding-compliant” NSManagedObject异常“此类不符合键值编码标准”,该应用在ios 6中崩溃,但适用于ios 5 - NSManagedObject exception “this class is not key value coding-compliant” and crashes the app in ios 6 but works for ios 5 每次我尝试运行我的应用程序时,它都会崩溃并给我这个错误,“这个 class 不符合键 tittleLabel 的键值编码。” - every time i try to run my app it crashes and gives me this Error, "this class is not key value coding-compliant for the key tittleLabel." 运行情节提要项目时,符合Monotouch键值编码的崩溃 - Monotouch key value coding-compliant crashes on running a storyboard project 将IBOulet添加到自定义UIView子类会崩溃“不符合键值” - Adding IBOulets to custom UIView subclass crashes 'is not key-value compliant' 如果滚动,UICollectionView应用程序将崩溃 - UICollectionView App crashes if scrolling 错误简单的应用程序,提示“此类不符合密钥的键值编码要求” - simple app with error “ this class is not key value coding-compliant for the key ”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM