iphone - UITableView custom cell can't scroll fluent,as database block my main thread -


i used multi column tableview !for 1 screen have 16 cells,and if have 3000 data ,and got thumbnail image database( use open source -fmdb),and when load table,i open 1 thread download thumbnail, , save database.

when cell visible,i got thumbnail db,if had been downloaded. found got data database slow,about 0.15~1.3 seconds 1 cell, , have 16 cell 1 screen. block main thread?

any suggestion me solve problem?

thanks in advance.

this code thumbnail~

   -(nsdata *)queryvideosmallthumbnaildata:(nsstring *)thesourceurl     {         if(thesourceurl == nil)             return nil;     nsstring *query = @"select small_thumbnail_data fields source_url";     query = [query stringbyappendingstring:@"=\""];     query = [query stringbyappendingstring:thesourceurl];     query = [query stringbyappendingstring:@"\""];      nsdata * data = nil;      fmresultset *rs = [database executequery:query];     while ([rs next])      {     data = [rs dataforcolumn:@"small_thumbnail_data"];     break;     }      [rs close];      return data;     } 

this table view refresh image code.

    image = [thumbcache getthumbfromcache:record.sourceurl]      if (image == nil)         {             dbvideothumb *thumbdb = [[dbmanager getinstance] getdbvideothumb];             nsdata *data = [thumbdb queryvideosmallthumbnaildata:record.sourceurl];             image = [uiimage imagewithdata:data];             if (image != nil)                 [thumbcache addthumbtocache:record.sourceurl image:image];         } 

the size of database may affect query speed. so, when table view dragging,you may change thumbnail small one. blur one, small possible.

create index database can improve query speed n log2 n. example :create index urlindex on fields(url);


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -