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.
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. 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!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.