iphone - Optimising UIScrollview for paging -


in continuation question asked here, want know if method update ui in viewdidscroll correct. can observe method called many times , may reason why ui become jittery , unresponsive. how can increase responsiveness of ui. code below:

bool isscrollingdown = verticalscrollview.contentoffset.y > _previouscontentoffsety;  _previouscontentoffsety = verticalscrollview.contentoffset.y;  cgfloat pageheight = verticalscrollview.frame.size.height;  int scrollingtopagenum = isscrollingdown ? (ceil((verticalscrollview.contentoffset.y - pageheight) / pageheight) + 1) : (floor((verticalscrollview.contentoffset.y - pageheight) / pageheight) + 1); int page = floor((verticalscrollview.contentoffset.y - pageheight / 2) / pageheight) + 1;  [self loadpage:(page-1)]; [self loadpage:(page)]; [self loadpage:(page+1)];  /* unloading pages not seen in view done here*/ if (!(isscrollingdown) && scrollingtopagenum >1) {     [self unloadpages:page-2]; }else {     [self unloadpages:page+2]; } 

the lazy loading technique works fine , lot of memory usage reduced due it. ui slow. want know how update ui different thread downloads image url.

tia, praveen

i'm not 100% sure double-check. have update screen in main thread of application if using apple's classes uiscrollview. however, don't need download images in same thread. read apple's concurrency guide , @ there sample program figure out how.

in addition takes longer draw images larger need be. don't draw images more pixel there space in view. super large images cut them apart draw sections @ time, apple has sample code this. when detect down time draw images around what's being displayed user. user doesn't see loading symbol when scrolling around view. there pre iphone 3gs can handle each ios release phone has gotten slower , slower, because it's doing more stuff have manage speed versus fidelity on phones, drawing low fidelity image if user rapidly moving around drawing higher fidelity image if user stops moving around.

i'll update later if have time links, tips above worked me.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -