Note that there are some explanatory texts on larger screens.

plurals
  1. POCell of UICollectionView not always refreshed after a scroll
    text
    copied!<p>I have defined in my Storyboard (iPad) a view that contains a <code>UICollectionView</code>, at the bottom of the view there's also a <code>UIToolbar</code>. In the <code>UICollectionView</code> I have added a <code>UICollectionViewCell</code> (implemented by an <code>iPadCellCollectionViewCell</code> class) that contains a another view that is a Core-Plot Graph (a <code>CPTGraphHostingView</code> class).</p> <p>I have a class called X that implements the <code>UICollectionViewDelegate</code> and <code>UICollectionViewDataSource</code>.</p> <p>In the class X, I build for each cell of my view (in <code>ViewDidLoad</code>) the Core-Plot Graph and I have the following code to link the graph to the cell of the <code>UICollectionViewCell</code></p> <pre><code>- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { static NSString* cellId = @"ChartCollectionId"; iPadCellCollectionViewCell* cell = [self.theCollectionView dequeueReusableCellWithReuseIdentifier:cellId forIndexPath:indexPath]; MyChart* chart = [_charts objectAtIndex:indexPath.row]; cell.hostingView.hostedGraph = chart.barChart; return cell; </code></pre> <p>}</p> <p>It's working fine, all my Graphs are correctly displayed on the screen. The issue happens when the user scroll the view, then one or several cells become "blank". I really don't understand why.</p> <p>I have found a workaround, instead of adding the <code>CPTGraphHostingView</code> in the <code>UICollectionViewCell</code> in the Interface Builder, I build it myself and the previous code becomes:</p> <pre><code>- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { static NSString* cellId = @"ChartCollectionId"; iPadCellCollectionViewCell* cell = [self.theCollectionView dequeueReusableCellWithReuseIdentifier:cellId forIndexPath:indexPath]; [cell.contentView addSubview:[_hostingViews objectAtIndex:indexPath.row]]; return cell; </code></pre> <p>}</p> <p>With this code everything is working fine. Is there any explanations why it's not working when I'm adding the <code>CPTGraphHostingView</code> in the <code>UICollectionViewCell</code> with the IB?</p> <p>Is it an issue to call "addSubview" each time the method is called? No memory leaks?</p>
 

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