title: Update not visible cells in UICollectionView
body: <p>I need an expandable UICollectionView in my app - so I came across this project (<a href="https://github.com/apploft/APLExpandableCollectionView" rel="nofollow noreferrer">https://github.com/apploft/APLExpandableCollectionView</a>). It's a subclass of UICollectionView that implements the expand and collapse behaviour.</p>
  
  <p>I have extended the demo app to display a + or a - button in the expandable cells.</p>
  
  <pre><code>- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  APLCollectionViewCell* cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"APLCollectionViewCell" forIndexPath:indexPath];
  
  if (indexPath.item == 0) {
      cell.label.text = [NSString stringWithFormat:@"Section %li", (long)indexPath.section + 1];
      cell.backgroundColor = [UIColor colorWithRed:58./255. green:165./255. blue:192./255. alpha:1.];
      cell.indentView.hidden = YES;
      cell.label_OnOff.text = @"+";
  } else {
      cell.label.text = [NSString stringWithFormat:@"Item %li", (long)indexPath.row];
      cell.backgroundColor = [UIColor colorWithRed:58./255. green:165./255. blue:192./255. alpha:.5];
      cell.indentView.hidden = NO;
      [cell.label_OnOff setHidden:YES];
  }
  
  return cell; 
  }
  </code></pre>
  
  <p>To switch between + and - I implemented the delegate methods:</p>
  
  <pre><code>- (void)collectionView:(UICollectionView *)collectionView didCollapseItemAtIndexPath:(NSIndexPath *)indexPath
  {
      APLCollectionViewCell *cell = (APLCollectionViewCell*)[collectionView cellForItemAtIndexPath:indexPath];
      cell.label_OnOff.text = @"+";
  }
  
  - (void)collectionView:(UICollectionView *)collectionView didExpandItemAtIndexPath:(NSIndexPath *)indexPath
  {
      APLCollectionViewCell *cell = (APLCollectionViewCell*)[collectionView cellForItemAtIndexPath:indexPath];
      cell.label_OnOff.text = @"-";
  }
  </code></pre>
  
  <p>As you can see in the screenshot, the visible cells are updated correctly. Once I scroll down to the former invisible cells, the + button disappears.
  This problem doesn't occur when there are only a few items in the UICollectionView, so that there is no need to scroll to further items.</p>
  
  <p><img src="https://i.stack.imgur.com/Yny6N.jpg" alt="Screenshot"></p>
  
  <p>Am I doing something wrong with IndexPath for invisble cells, or do you have any other hints for me?
  Thank you!</p>