简体   繁体   中英

Save Screenshot to Custom Photo Album

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

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/

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM