Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>f you consider the below 3 things,you will not have any delay while loading Photo-library images </p> <p><strong>1. Store only the <code>ALAsset URL</code> into your <code>NSMutableArray</code> instead of <code>ALAsset</code></strong></p> <p>If you are using UIImagePicker, you can get it the URL through didFinishPickingMediaWithInfo delegate</p> <p><code>NSURL* mediaUrl = [info valueForKey:UIImagePickerControllerMediaURL]</code>;</p> <p><strong>2.Use the ALAsset <code>aspectRatioThumbnail</code> instead of <code>fullResolutionImage</code></strong></p> <pre><code> CGImageRef iref = [myasset aspectRatioThumbnail]; UIImage *loadedImage = [UIImage imageWithCGImage:iref]; </code></pre> <p><strong>3. Do the UI related stuffs in main thread.</strong></p> <p>Because <code>ALAssetsLibrary</code> block will execute in separate thread. So the performance will improve when doing UI related stuffs in main thread.</p> <p>To do this either use </p> <p><code>dispatch_sync(dispatch_get_main_queue()</code> or <code>performSelectorOnMainThread</code></p> <p><strong>Example:</strong></p> <pre><code> dispatch_sync(dispatch_get_main_queue(), ^{ cell.imageView.image = [UIImage imageWithCGImage:iref]; });//end block </code></pre> <p><strong>Final code should be look like as below</strong> </p> <pre><code>ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset){ dispatch_sync(dispatch_get_main_queue(), ^{ GImageRef iref = [myasset aspectRatioThumbnail]; cell.imageView.image = [UIImage imageWithCGImage:iref]; });//end block }; ALAssetsLibraryAccessFailureBlock failureblock = ^(NSError *myerror) { NSLog(@"Cant get image - %@",[myerror localizedDescription]); }; ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init]; // USE ALAssetsLibrary as single-tone or global while using ARC [assetslibrary assetForURL:asseturlFromYourArray resultBlock:resultblock failureBlock:failureblock]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload