Saving Image to User Library

I have an application that stores images in a user library in a photo album on iphone.

I called the following ALAssetLibrary function

-(void)saveImage:(UIImage*)image toAlbum:(NSString*)albumName withCompletionBlock:(SaveImageCompletion)completionBlock
{
    //write the image data to the assets library (camera roll)
    [self writeImageToSavedPhotosAlbum:image.CGImage orientation:(ALAssetOrientation)image.imageOrientation 
                        completionBlock:^(NSURL* assetURL, NSError* error) {

                          //error handling
                          if (error!=nil) {
                              completionBlock(error);
                              return;
                          }

                          //add the asset to the custom photo album
                          [self addAssetURL: assetURL 
                                    toAlbum:albumName 
                        withCompletionBlock:completionBlock];

                      }];
}

in my SaveImage IBAction

-(IBAction)saveToLib:(id)sender
{
    UIImage *savedImage = imgPicture.image;
    NSLog(@"Saved Image%@",savedImage);
    [self.library saveImage:savedImage toAlbum:@"Touch Code" withCompletionBlock:^(NSError *error) {
        if (error!=nil) {
            NSLog(@"Big error: %@", [error description]);
        }
    }];
}

but my app keeps getting crashed help me out Thanks in Advance

+5
source share
2 answers

It seems that you are incorrectly calling [self.library saveImage: savedImage toAlbum: @ ....]. If you are following this website , add #import "ALAssetsLibrary + CustomPhotoAlbum.h" to your view controller.

Not sure if this is a problem. Sorry if this is the wrong decision.

0
source

- -, .

, , .

, - ...

0

All Articles