【发布时间】:2013-06-26 16:22:08
【问题描述】:
我有一个承载 UICollectionview 的情节提要,在 collectionviewcontroller 中我实现了
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
itemViewCell *itemCell =
[collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier
forIndexPath:indexPath];
return itemCell;
}
但在 dequeueReusableCellWithReuseIdentifier 上,应用程序会抛出此异常:
[__NSCFConstantString initWithFrame:]: unrecognized selector sent to instance 0x7443c60
所以我的第一个倾向是查看我正在创建的自定义单元格,以确保我有该方法的实现,并且我确实这样做了
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor whiteColor];
}
return self;
}
当然,我正在 viewdidload 中注册该单元格
[super viewDidLoad];
[self.collectionView registerClass:[CellIdentifier class]
forCellWithReuseIdentifier:CellIdentifier];
但我不认为这是相关的,因为我在 initWithFrame 方法上放了一个断点,它永远不会热它。我做错了什么。
【问题讨论】:
标签: ios objective-c ios6 uicollectionview