0

I am using this code to save image into the album but images are being saved in Camera Roll album. I want to save images in WEAVE album. I'm using this code:

CGRect screenRect=CGRectMake(0, 0, viewPlay.frame.size.width, viewPlay.frame.size.height);
UIGraphicsBeginImageContext(screenRect.size);
CGContextRef ctx=UIGraphicsGetCurrentContext();
[[UIColor whiteColor] set];
CGContextFillRect(ctx, screenRect);
[self->viewPlay.layer renderInContext:ctx];
UIImage *screenImage=UIGraphicsGetImageFromCurrentImageContext();
UIImageWriteToSavedPhotosAlbum(screenImage, nil, nil, nil);
UIGraphicsEndImageContext();

this code is working fine for me. please give me any suggestion what change i do here to save image into WEAVE folder.

1 Answers1

0

You can use the following code for doing this:

ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];

[library saveImage:image toAlbum:@"Midhun" withCompletionBlock:^(NSError *error) {
        if (error!=nil)
        {
            NSLog(@"Error: %@", [error description]);
        }
    }];

Check this tutorial also: Custom Photo Album

For more info about ALAssetsLibrary

Midhun MP
  • 103,496
  • 31
  • 153
  • 200
  • Thanks for your answer. I tried that but this code saving picture only once. I want to save more then one pictures in that album. how to fix this bug? please help me. –  Jan 16 '13 at 05:47
  • @SanjayJoshi: means what happened when you passed another image on that function ? – Midhun MP Jan 16 '13 at 05:49
  • its not saving that another image into the same folder. –  Jan 16 '13 at 06:07
  • Can you help me again? i want to change the name of the images while saving. How to do it? –  Jan 18 '13 at 06:08
  • @SanjayJoshi: you mean to save the file in photolibrary with a name ? – Midhun MP Jan 18 '13 at 06:16
  • yes. while i click on save button it should show a prompt to enter file name –  Jan 18 '13 at 08:35
  • @SanjayJoshi: you cannot save photo library with custom name. I'll suggest that, keep a database for storing the file name and file url. – Midhun MP Jan 18 '13 at 08:38
  • Midhun as I'm new to iOS, I don't know how to create database in iOS. do you have any tutorial to learn it. If you have that will help me very much. thanks for your responses. –  Jan 18 '13 at 10:07
  • @SanjayJoshi: please check these links http://www.techotopia.com/index.php/An_Example_SQLite_based_iOS_4_iPhone_Application, http://stackoverflow.com/questions/716839/wheres-the-best-sqlite-3-tutorial-for-iphone-sdk, http://stackoverflow.com/questions/5891031/ios-offline-data-storage-tutorial – Midhun MP Jan 18 '13 at 10:15