Posted By

arpit on 07/21/09


Tagged

UIImage


Versions (?)

Save Image to Photo Lib rary


 / Published in: Objective C
 

URL: http://iphonesdksnippets.com/post/2009/05/12/Save-image-to-image-library.aspx

  1. -(void)savePictureToLibrary{
  2.  
  3. UIImage *img = [[UIImage imageNamed:@"image.png"];
  4.  
  5. UIImageWriteToSavedPhotosAlbum(img, self, @selector(image:didFinishSavingWithError:contextInfo:), self);
  6.  
  7. }
  8.  
  9.  
  10. - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo{
  11.  
  12. NSString *str = @"Saved!!!";
  13.  
  14. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Saved." message:str delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
  15.  
  16. [alert show];
  17.  
  18. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: FGRINGO on May 13, 2011

Hi, i used this same method or similar:

-(IBAction)screenShot{ maintimer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(update) userInfo:nil repeats:YES]; }

-(void)update{

time = time + 1;
if(time == 2){
    [self hideThem]; //hides the buttons
    UIGraphicsBeginImageContext(self.bounds.size);
    [self.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *screenImage = [UIImage imageNamed:@"SCREENSHOT.png"];
    screenImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    UIImageWriteToSavedPhotosAlbum(screenImage, self, nil, self);
    NSLog(@"%@", screenImage);
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"GRAPH SAVED" message:@"YOUR GRAPH HAS BEEN SAVEN IN THE PHOTO ALBUM" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
    [alert release];
    [maintimer invalidate];
    time = 0;
}
[self bringThem]; //brings the buttons back

}

But now i need to know how to bring this picture back so i can post it in a email. How can i get this printscreen back? Thanks.

You need to login to post a comment.