【发布时间】:2014-06-13 13:48:08
【问题描述】:
我正在使用 UICollectionView 和自定义 UICollectionViewCell。
我使用以下方法创建了一个空单元格:
[[MyCell alloc] init];
编译器抛出错误:
Assertion failure in -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:]
我在viewDidLoad:方法中尝试了以下:
[self.collection registerClass:[MyCell class] forCellWithReuseIdentifier:@"MyCell"];
然后在- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath方法中:
MyCell *cell = [[MyCell alloc] init];
【问题讨论】:
-
这可能是因为您没有使用任何
reuseIdentifier -
@Morpheus 你有什么建议?
标签: ios objective-c ios7 uicollectionview uicollectionviewcell