Note that there are some explanatory texts on larger screens.

plurals
  1. POfetching photo alassetlibrary asset representation size zero
    primarykey
    data
    text
    <p>When I am fetching photos using the ALAssetLibrary, for some images, the AssetRepresentation.size comes zero, which does not make the image, on my ImageView. Here is the code:</p> <pre><code>ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; [library enumerateGroupsWithTypes:ALAssetsGroupAlbum usingBlock:^(ALAssetsGroup *group, BOOL *stop) { if ([[group valueForProperty:ALAssetsGroupPropertyName] isEqual:self.groupName]) { [group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop){ //Get the asset type NSString *assetType = [result valueForProperty:ALAssetPropertyType]; if ([assetType isEqualToString:ALAssetTypePhoto]) { NSLog(@"Photo Asset"); } //Get URLs for the assets NSDictionary *assetURLs = [result valueForProperty:ALAssetPropertyURLs]; NSUInteger assetCounter = 0; for (NSString *assetURLKey in assetURLs) { assetCounter++; } //Get the asset's representation object ALAssetRepresentation *assetRepresentation = [result defaultRepresentation]; //From this asset representation, we take out data for image and show it using imageview. dispatch_async(dispatch_get_main_queue(), ^(void){ CGImageRef imgRef = [assetRepresentation fullResolutionImage]; //Img Construction UIImage *image = [[[UIImage alloc] initWithCGImage:imgRef] autorelease]; NSLog(@"before %@:::%lld", [image description], [assetRepresentation size]); //Prints '0' for size if((image != nil)&amp;&amp; [assetRepresentation size] != 0){ //display in image view } else{ // NSLog(@"Failed to load the image."); } }); }]; } }failureBlock:^(NSError *error){ NSLog(@"Error retrieving photos: %@", error); }]; [library release]; </code></pre> <p>Please Help. What am I doing wrong here? and how should I get the image?</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.
    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