iOS SIGABRT on dequeueReusableCellWithReuseIdentifier [duplicate]

别来无恙 提交于 2020-02-06 02:57:06

问题


I'm trying to get a UICollectionView working in my application and for some reason I keep getting a sigabrt. The error I am getting is

* Assertion failure in -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:]

I have googled around, and it seems like most of the time this is related to the neglecting to registerClass forCellWithReuseIdentifier, but I am doing this as required in the view did load method. My code is as follows:

 - (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"Cell"];
    [self.collectionView reloadData];
    self.refreshControl = [[UIRefreshControl alloc]init];
    [self.collectionView addSubview:self.refreshControl];

}

- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    UICollectionViewCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"Cell " forIndexPath:indexPath];
    cell.backgroundColor = [UIColor whiteColor];
    return cell;
}

Does anyone know what I might be missing?


回答1:


one cell identifier is "Cell" & another one is "Cell ". i.e. extra space after cell, remove it.



来源:https://stackoverflow.com/questions/16866624/ios-sigabrt-on-dequeuereusablecellwithreuseidentifier

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!