简体   繁体   English

在调试崩溃应用程序时出队 UICollectionViewCell

[英]dequeuing UICollectionViewCell while debugging crashes app

I'm trying to debug my app, but when I run it through Xcode, I get a crash saying -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:viewCategory:] This happens in cellForItemAtIndexPath : for the collection view, but it only happens when I'm debugging, if I install the app and run it without Xcode it works fine.我正在尝试调试我的应用程序,但是当我通过 Xcode 运行它时,我得到一个崩溃消息-[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:viewCategory:]这发生在cellForItemAtIndexPath :对于集合视图,但它只发生在我正在调试,如果我安装应用程序并在没有 Xcode 的情况下运行它,它可以正常工作。

this is my code:这是我的代码:

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

So I figured this out, and hopefully this will help someone else.所以我想出了这个,希望这会帮助别人。 In my case, I have a UICollectionViewCell in a .Xib file.就我而言,我有一个UICollectionViewCell中的.xib文件。 That cell has a UIScrollView and that UIScrollView has a UIView in it.该单元格有一个UIScrollView ,而UIScrollView有一个UIView 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. UIView比屏幕高,所以在 IB 中我把它从滚动视图中拉出来,这样我就可以看到它,但我从来没有把它移回滚动视图的子视图。 Long story short, if you build a custom UITableViewCell or UICollectionViewCell, everything has to be a subview of the Cell, otherwise, CRASH!长话短说,如果你构建一个自定义的 UITableViewCell 或 UICollectionViewCell,一切都必须是 Cell 的子视图,否则,崩溃!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM