ios - UICollectionView Store cells in array for quick loading -


i have question, not sure if possible, thought ask advice on here!

i have app, , uses uicollectionview present grid of buttons user. using bootstrap-style gradient buttons, draw each cell (there can 40 buttons in 1 'grid'), uses system resources, , redrawing can take time (well - half second!). user can load different sets collection view well. in order circumvent loading time, possible hold of cells in array, , instead of configuring each cell when -cellforrowatindexpath called, pull cell array?

i not sure if done thing. app has loading screen, array can populated @ startup.

thanks, paul

you can use nscache hold drawn cells,

1) @property(nonatomic, strong) nscache *mycache;

2) in viewdidload,

self.mycache = [[nscache alloc] init];

3) use these 2 methods,

-(id) cellforindexpathrow:(nsnumber *) number{     return [self.mycache objectforkey:number]; }  -(void) setcell:(id) cell forindexpathrow:(nsnumber *) number{     [self.mycache setobject:cell forkey:number]; } 

4) when draw cell,

first call

id cell = [self cellforindexpathrow:[nsnumber numberwithint:indexpath.row]]; if(!cell){  //then create draw cell   //store drawn cell in cache       [self setcell:cell forindexpathrow:[nsnumber numberwithint:indexpath.row]]; } 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -