1

私はUICollectionViewを使用して、iPadでグリッドベースのビューを表示しています。画面には一度に200(20行x 10列)のセルしかありません。各セルには1つのUILabelのみが含まれています。TableViewのように、スクロールが遅くなり、スムーズになりません。

このスクロールパフォーマンスが遅い理由はわかりません。どうすれば改善できますか?

前もって感謝します!


私は3つのcollectionviewsを持っていますが、メインコンテンツのuicollectionviewは2とタグ付けされたものです。これが私のコードです

if (collectionView.tag==0) { //This tagged collection view is for Left side selection box

    LeftSelectionBoxItem *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"SelectionCell" forIndexPath:indexPath];

    return cell;
}
else if (collectionView.tag==1){ //This tagged collection view is for to show column names

    TopColumnItem *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ColumnCell" forIndexPath:indexPath];
    cell.columnName.text = [NSString stringWithFormat:@"%@",[self.columnNames objectAtIndex:indexPath.item]];

    return cell;
}
else if (collectionView.tag==2) { //This tagged collection view is for to show main content

    GridItem *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"GridCell" forIndexPath:indexPath];
    cell.dataLabel.text = [NSString stringWithFormat:@"%@",[[self.dataModel objectAtIndex:indexPath.section] objectForKey:[self.columnNames objectAtIndex:indexPath.item]]];

    return cell;
}
else {
    return nil;
}
4

1 に答える 1

3

UILabelをたくさん持つと、コストがかかる場合があります。オーバーヘッドがはるかに少ないため、代わりにCATextLayersに変更してみてください。これを行ってラスタライズを使用する場合は、網膜ディスプレイデバイスでもラスタライズするようにレイヤーに指示する必要があることに注意してください。

于 2012-12-14T12:36:11.230 に答える