Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling UICollectionView#reloadData in UICollectionViewDelegate#collectionView:didSelectItemAtIndexPath: hides all cells
    primarykey
    data
    text
    <p>I have a UIViewController which has the following implementation for the didSelectItemAtIndexPath</p> <pre><code>@interface id section1Item NSMutableArray *section2Items NSMutableArray *section3Items @end @implementation - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section == 0) { ; } else if (indexPath.section == 1) { self.section1Item = [self.section2Items objectAtIndex:indexPath.row]; } else { // indexPath.section == 2 id newSection2Item = [self.section3Items objectAtIndex:indexPath.row]; [self.section2Items addObject:newSection2Item]; [self.section3Items removeObject:newSection2Item]; } [collectionView reloadData]; } @end </code></pre> <p>The idea behind the code is that my collectionView has a static number of sections, and taping on an item in section 3 moves the item to section 2, and tapping on an item in section 2 makes it an item in section 1. </p> <p>However once I make the changes to my dataStructure (section1Item, section2Items and section3Items), and call reloadData, all my UICollectionView cells disappear. A few symptoms of the issue</p> <ol> <li>After the reloadData call, non of my dataSource methods get recalled. I tried putting a breakpoint in my implementation of numberOfSectionsInCollectionView and collectionView:numberOfItemsInSection but they don't get hit.</li> <li>I tried debugging using RevealApp, and I found out that after reloadData call, all my UICollectionViewCell's have their hidden property set to "YES", even though I don't have any code in my code base calling .hidden = YES;</li> <li>I also tried overriding UICollectionViewCell#setHidden to detect what (if any) part of the UIKit framework calls it, and again there was no breakpoint triggers.</li> </ol> <p>Tools details: I'm working with XCode5-DP6 on iOS7 simulator.</p> <p><strong>UPDATE:</strong> My UICollectionView shows all the cells correctly on first render.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload