`
janedoneway
  • 浏览: 570329 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

iphone 保存图片到照片库

 
阅读更多

From: http://my.oschina.net/ahuaahua/blog/15182

 

 

保存已知图片:

 

UIImageWriteToSavedPhotosAlbum([UIImage imageNamed:photoName], self@selector(image:didFinishSavingWithError:contextInfo:), nil);


 

- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo

{

UIAlertView *alert;

    if (error == nil)

{

alert = [[UIAlertView allocinitWithTitle:nil message:@"This picture has been saved to your photo album.Picture Saved!" delegate:nilcancelButtonTitle:@"OK." otherButtonTitles:nil];

[alert show];

[alert release];

}

else

{

alert = [[UIAlertView allocinitWithTitle:nil message:@"Please try it again later.Saving Failed" delegate:nilcancelButtonTitle:@"OK." otherButtonTitles:nil];

[alert show];

[alert release];

}

}

 


保存当前视图:

 

#import <QuartzCore/QuartzCore.h>

UIGraphicsBeginImageContext(currentView.bounds.size); //currentView当前的view

[currentView.layer renderInContext:UIGraphicsGetCurrentContext()];

UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

UIImageWriteToSavedPhotosAlbum(viewImage, nilnilnil);

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics