Click the button to save the image above Self.imageview to your local album and specify a method to determine the success of the Save Imagesavedtophotosalbum:didfinishsavingwitherror: ContextInfo:
-(Ibaction) Saveimagetoalbum: (ID) Sender {
Uiimagewritetosavedphotosalbum (Self.imageView.image, Self, @selector (imagesavedtophotosalbum: Didfinishsavingwitherror:contextinfo:), nil);
}
Implementing ImageSavedToPhotosAlbum:didFinishSavingWithError:contextInfo: Methods
-(void) Imagesavedtophotosalbum: (UIImage *) image didfinishsavingwitherror: (nserror *) error ContextInfo: (void *) ContextInfo
{
NSString *message = @ "hehe";
if (!error) {
Message = @ "Successfully saved to album";
}else
{
message = [error description];
}
NSLog (@ "message is%@", message);
}
The code is simple, if there is no error, prompt "successfully saved to the album", if the save fails, then output error message ["Error description]."
Save IOS Pictures to a local album