在调试崩溃应用程序

时间:2016-07-10 23:24:37

标签: ios objective-c uicollectionview

我正在尝试调试我的应用程序,但是当我通过Xcode运行它时,我得到一个崩溃说-[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:viewCategory:]这发生在cellForItemAtIndexPath:对于集合视图,但它只发生在我调试,如果我安装应用程序并在没有Xcode的情况下运行它可以正常工作。

这是我的代码:

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    FFSIncidentCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath]; 
    // Configure the cell 
    ...
}

1 个答案:

答案 0 :(得分:0)

So I figured this out, and hopefully this will help someone else. In my case, I have a UICollectionViewCell in a .Xib file. That cell has a UIScrollView and that UIScrollView has a UIView in it. The UIView is taller than the screen, so in IB I pulled it out of the scroll view so I could see it all, but I never moved it back to being a subview of the scroll view. Long story short, if you build a custom UITableViewCell or UICollectionViewCell, everything has to be a subview of the Cell, otherwise, CRASH!