Note that there are some explanatory texts on larger screens.

plurals
  1. POImage loading with GCD receiving memory warning
    primarykey
    data
    text
    <p>I'm developing a photo gallery application using AssetsLibrary to load my device photos. When presenting a random image in another VC I've noticed the following : it takes about 1 or 2 seconds for my full res image to load on the imageView (way much longer than the native photosApp) and I also get from the log "Received memory warning" after loading a few images. If I set my representation to fullScreenImage the warnings stop but I don't want this. What must I change for a smooth performance and high quality images on the view ? </p> <p>Here's the code,hope you can tell me what's the problem :</p> <p>This is the VC where I want to present my image on the screen</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; NSLog(@"%@",assetsController); detailImageView = [[UIImageView alloc]initWithFrame:self.view.bounds]; [self.view addSubview:detailImageView]; detailImageView.image = smallImage; //small image is my asset thumbnail and is passed as an argument in my init function dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; ALAsset *asset = [assetsController.albumPics objectAtIndex:assetsController.index]; ALAssetRepresentation *representation = [asset defaultRepresentation]; bigImage = [[UIImage imageWithCGImage:[representation fullResolutionImage]]retain]; dispatch_async(dispatch_get_main_queue(), ^{ detailImageView.image = bigImage; }); [pool release]; }); } </code></pre> <p><strong>UPDATE 1</strong></p> <pre><code> { UIImageView *detailImageView = [[UIImageView alloc]initWithFrame:self.view.bounds]; [self.view addSubview:detailImageView]; detailImageView.image = smallImage; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; ALAsset *asset = [assetsController.albumPics objectAtIndex:assetsController.index]; ALAssetRepresentation *representation = [asset defaultRepresentation]; UIImage *bigImage = [UIImage imageWithCGImage:[representation fullResolutionImage]]; dispatch_async(dispatch_get_main_queue(), ^{ detailImageView.image = bigImage; }); [pool release]; }); } </code></pre> <p><img src="https://i.stack.imgur.com/ubI4H.png" alt="enter image description here"></p>
    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.
 

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