Reputation: 2340
I'm using UICollectionView to show grid based View in iPad. I have only 200 (20rows x 10 columns) cells at a time on screen, each cell contain one UILabel only. It starts to get slower on scrolling and not smooth like in TableView.
I don't know the reason for this slower scrolling performance. How do I improve?
Thanks in advance!
I have 3 collectionviews, but the main content uicollectionview is the one which has been tagged 2. Here is my code
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;
}
Upvotes: 1
Views: 3525
Reputation: 20257
Having a lot of UILabels is sometimes expensive. Try changing them to CATextLayers instead, as these have much less overhead. Note that if you do this and use rasterizing, you will need to tell the layer to rasterize for retina display devices too.
Upvotes: 3