Note that there are some explanatory texts on larger screens.

plurals
  1. POLoading image from ios assetlibrary
    primarykey
    data
    text
    <p>I am using following code to load image from assetlibrary. It's not working and if I click on displayImage uiimageviewer it shows invalid attempt to access past the lifetime of its owning ALAssetsLibrary.</p> <p>Header File</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; #import "BFCropInterface.h" #import "GRKImage.h" #import &lt;AssetsLibrary/AssetsLibrary.h&gt; @interface BFViewController : UIViewController{ GRKImage *gImg; } @property (nonatomic, strong) IBOutlet UIImageView *displayImage; @property (nonatomic, strong) UIImage *originalImage; @property (nonatomic, strong) BFCropInterface *cropper; @property (nonatomic, retain) GRKImage *gImg; @property (strong, atomic) ALAssetsLibrary* library; - (IBAction)cropPressed:(id)sender; - (IBAction)originalPressed:(id)sender; - (IBAction)savePressed:(id)sender; @end </code></pre> <p>Main file : inside viewDidload</p> <pre><code>if ( [[self.gImg.URL absoluteString] hasPrefix:@"assets-library://"] ){ typedef void (^ALAssetsLibraryAssetForURLResultBlock)(ALAsset *asset); typedef void (^ALAssetsLibraryAccessFailureBlock)(NSError *error); ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset){ ALAssetRepresentation *rep = [myasset defaultRepresentation]; CGImageRef iref = [rep fullResolutionImage]; float scale=[rep scale]; ALAssetOrientation orientation=[rep orientation]; if (iref){ dispatch_async(dispatch_get_main_queue(), ^{ UIImage *originalImage = [UIImage imageWithCGImage:iref scale:scale orientation:(UIImageOrientation)orientation]; self.displayImage.contentMode = UIViewContentModeScaleAspectFit; [self.displayImage setImage:originalImage]; }); } }; ALAssetsLibraryAccessFailureBlock failureblock = ^(NSError *myerror){ //failed to get image. }; self.library = [[ALAssetsLibrary alloc] init]; [self.library assetForURL:self.gImg.URL resultBlock:resultblock failureBlock:failureblock]; } </code></pre>
    singulars
    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. 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