我正在尝试使用我创建的子类UICollectionViewCell。
子类中唯一的区别是单元格具有imageView属性。我每件事都是按程序进行的--没有故事板或笔尖
- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath {
PFUICollectionViewCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"FlickrCell" forIndexPath:indexPath];
cell.backgroundColor = [self generateRandomUIColor];
NSURL *staticPhotoURL = [self.context photoSourceURLFromDictionary:[self.photos objectAtIndex:indexPath.row] size:OFFlickrSmallSize];
**if (cell.imageView) {**
cell.imageView = [self.pfImageViewArray objectAtIndex:indexPath.row];
return cell;
}
}
但是,当我试图检查单元格imageView属性是否实例化时,我得到,
由于未识别的异常“NSInvalidArgumentException”终止应用程序,原因:-UICollectionViewCell imageView:发送到实例的未识别选择器
就像细胞不知道它是一个PFUICollectionViewCell,而且仍然认为它是一个UICollectionViewCell。
我知道这很简单,但我不知道我做错了什么,
谢谢,约翰
发布于 2014-02-08 03:39:54
在-viewDidLoad
方法中添加下面的代码(或者在创建UICollectionView实例之后):
[collectionView registerClass:[PFUICollectionViewCell class]
forCellWithReuseIdentifier:@"FlickrCell"];
UPD:
在评论中还没有看到这个答案。
https://stackoverflow.com/questions/21645311
复制相似问题