ios - populating images in UIScrollView. And how to do it lazily -


well usual domain now, have managed functionality, need make better.

i trying populate recent images camera roll. i'm pretty sure there more elegant way it. thing thats making me uneasy is,

block > loop > block better solution or simplification appreciated.

  alassetslibrary *assetslibrary = [[alassetslibrary alloc] init]; [assetslibrary enumerategroupswithtypes:alassetsgroupsavedphotos                              usingblock:^(alassetsgroup *group, bool *stop) {                                  if (nil != group) {                                       [group setassetsfilter:[alassetsfilter allphotos]];                                      nslog(@"%d images found", group.numberofassets);                                      for(int = group.numberofassets - 5; i<group.numberofassets - 1; i++){                                       [group enumerateassetsatindexes:[nsindexset indexsetwithindex:i]                                                              options:0                                                           usingblock:^(alasset *result, nsuinteger index, bool *stop) {                                                               if (nil != result) {                                                                   alassetrepresentation *repr = [result defaultrepresentation];                                                                    uiimage *img = [uiimage imagewithcgimage:[repr fullresolutionimage]];                                                                    cgfloat aspectratio = img.size.width/img.size.height;                                                                   uiimageview *imgview = [[uiimageview alloc] init];                                                                    imgview.frame = cgrectmake(10, self.ycord, 300, 300 /aspectratio);                                                                    self.ycord += margin + (300/aspectratio);                                                                    imgview.image = img;                                                                    imgview.layer.shadowradius = 5.0;                                                                   imgview.layer.shadowcolor = [uicolor blackcolor].cgcolor;                                                                    [self.scroll addsubview:imgview];                                                                    *stop = yes;                                                                   self.scrollviewheight = self.ycord + imgview.frame.size.height + margin;                                                                   cgsize scrollviewsize = cgsizemake(320, self.scrollviewheight);                                                                   [self.scroll setcontentsize:scrollviewsize];                                                                }                                                           }];}                                  }                                   *stop = no;                              } failureblock:^(nserror *error) {                                  nslog(@"error: %@", error);                              }]; 

also how make images lazy load. have paging disabled now, , images load simultaneously, hazardous in cases.

actually should use nsoperation , nsoperationqueueclass purpose or can use gcd same too. if guide reference corresponding classes find nsoperation , nsoperation classes has high level flexibility comparability gcd. here going give reference of tutorial @ can idea how use these mention useful class such purpose efficiently.

here link nsoperation in tutorial writer mention evreything in detail, pretty sure helps if nsoperation , nsoperationqueue use in doing same task i.e downloading images or fetching images camera in background efficiently.

here tutorial gcd.

here i'll tell you, why have given these tutorial references because these tutorial gives lot of in implementing such thing efficiently.

hey friend try point form above, here have introduced experience only.it's how takes reference.

i feel happy if idea above.

edit: friend don't forget important part of requirement minimum memory occupation classes (uiscrollview). think suppose there many images in camera , need fetch images might in hundreds of in terms of numbers suppose going show images on uiimageview. here need follow concept of infinite scrollview(creates 3 mainview refresh data on these mainview ). i.e create 3 mainview view1(this treat right view), view2(would treat center) , view3(seems left). need write code in such way need these view allocate , add uiimageviews on these 3 views.you need use delegate of uiscrollview managing things. here have given logic , have go through on , forcing you should follow thing in app, sake sake of high speed app should think on it. can many of thread on internet same logic , find many tutorials logic. , please don't try blame me in case of if don't able same, here given opinion better development.

i hope understand views.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -