私のストーリーボード(iPad)にはUICollectionView
を含むビューが定義されています。ビューの最下部にはUIToolbar
もあります。 UICollectionView
には、(iPadCellCollectionViewCell
クラスで実装されています)に、コアプロットグラフ(CPTGraphHostingView
クラス)の別のビューが含まれています。スクロール後にUICollectionViewのセルが常にリフレッシュされない
私はUICollectionViewDelegate
とUICollectionViewDataSource
を実装するXというクラスを持っています。クラスXで
、私は私のビュー(ViewDidLoad
で)コアプロットグラフの各セルのために構築し、私はUICollectionViewCell
- (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;
}のセルにグラフをリンクするために、次のコードを持っています
正常に動作しているため、すべてのグラフが画面に正しく表示されています。この問題は、ユーザーがビューをスクロールしたときに1つまたは複数のセルが「空白」になるときに発生します。なぜ私は本当に理解していない。
私が代わりにInterface BuilderでUICollectionViewCell
で
CPTGraphHostingView
を追加するので、私はそれを自分自身を構築し、前のコードとなり、回避策を発見した
:
- (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;
}
をこのコードのすべてでありますうまく動作します。 UICollectionViewCell
のCPTGraphHostingView
をIBに追加するときに、なぜ機能しないのか説明がありますか?
メソッドが呼び出されるたびに「addSubview」を呼び出すのは問題ですか?メモリリークはありませんか?
どこで私はそのバグレポートを見ますか? – bandejapaisa