[英]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.