1
我正在嘗試在我的應用程序中獲取UICollectionView,並且出於某種原因我不斷收到sigabrt。我得到的錯誤是關於dequeueReusableCellWithReuseIdentifier的iOS SIGABRT
*斷言失敗 - [UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:]
我用Google搜索周圍,似乎像極了,這是關係到忽略了時間registerClass forCellWithReuseIdentifier,但我按照需要在視圖中執行加載方法。我的代碼如下:
- (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;
}
有誰知道我可能會錯過什麼?
應該有另一行解釋具體問題的錯誤消息。嘗試點擊Xcode調試器中的Continue,直到應用程序崩潰;您可能會在調試控制檯中獲得更多輸出。 –
如果您正確複製了代碼,那麼您的單元標識符不匹配。 – Wain
哈哈,就是這樣。在單元格標識符中輸入錯字!謝謝! – akhalsa