0

I am currently in the process in creating a new app which analyses certain aspects of the user and makes the funny.

I am stuck on one part though, at the end of the app, when the user gets their results back, I want it so they can save it to a custom Album specifically for screenshots from this app.

-(IBAction)save:(id)sender {
toolBar.hidden = YES;

[self performSelector:@selector(screenPause) withObject:nil afterDelay:0.001];
}
-(void)screenPause {
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
screenshotImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
 UIImageWriteToSavedPhotosAlbum(screenshotImage, nil, nil, nil);
[self performSelector:@selector(screenPauseOne) withObject:nil afterDelay:0.001];

}

This is how I am currently capturing the screen. And as you can see, I am just saving it to the default album. How would I create a new album and then place captured images into it?

Thanks in advance, Rafee

RafeeJ
  • 441
  • 2
  • 6
  • 14

2 Answers2

0

You need to use the AssetsLibrary framework.

Here is a tutorial that explains how to do it:

http://www.touch-code-magazine.com/ios5-saving-photos-in-custom-photo-album-category-for-download/

Felix
  • 35,354
  • 13
  • 96
  • 143
  • I'm sorry, but could you explain what I need to use from that. I have tried to follow that tutorial but I found no luck. Could you explain step by step? – RafeeJ Jun 23 '13 at 20:44
  • That helper class looks useful: https://gist.github.com/sapzildj/2773458 Just call `[ALAssetsLibraryUtil saveImage:img toAlbum:@"myAlbum" withCompletionBlock:block]` – Felix Jun 23 '13 at 20:48
  • I have just edited my question with my full code. I still don't understand how to implement this! I'm sorry if I am being to n00by! XD – RafeeJ Jun 28 '13 at 19:57
0

To my understanding what phix23 is telling you is that the code you are looking for is:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
  [self.library saveImage:image toAlbum:@"YourCustomAlbumName" withCompletionBlock:^(NSError *error) {
    if (error!=nil) 
    {
        NSLog(@"Big error: %@", [error description]);
    }
  }];

[picker dismissModalViewControllerAnimated:NO];
}

The block code starting with [self is where the magic happens.

sangony
  • 11,636
  • 4
  • 39
  • 55
  • I have implemented this, but it just comes up with a new album called HUD and the image isn't saved in the camera roll either. What am I doing wrong? – RafeeJ Jul 04 '13 at 20:42
  • OK. Take a look at this previous Q&A which is identical to your current question. http://stackoverflow.com/questions/10954380/save-photos-to-custom-album-in-iphones-photo-library – sangony Jul 05 '13 at 13:44