@interface Viewcontroller ()
void Uiimagewritetosavedphotosalbum (
UIImage * image,
ID Completiontarget,
SEL Completionselector,
void *contextinfo
);
@end
@implementation Viewcontroller
-(void) Viewdidload {
[Super Viewdidload];
Additional setup after loading the view, typically from a nib.
UIImage *imagname = [UIImage imagenamed:@ "submit"];
[Self saveimagetophotos:imagname];
}
-(void) Saveimagetophotos: (uiimage*) Savedimage
{
Uiimagewritetosavedphotosalbum (Savedimage, Self, @selector (image:didFinishSavingWithError:contextInfo:), NULL);
}
Specifying callback methods
-(void) Image: (UIImage *) image didfinishsavingwitherror: (nserror *) error ContextInfo: (void *) ContextInfo
{
NSString *msg = nil;
if (Error! = NULL) {
msg = @ "Save picture failed";
}else{
msg = @ "Save picture Success";
}
Uialertview *alert = [[Uialertview alloc] initwithtitle:@ "Save picture result hint"
Message:msg
Delegate:self
cancelbuttontitle:@ "OK"
Otherbuttontitles:nil];
[Alert show];
}
-(void) Touchesbegan: (nsset *) touches withevent: (uievent *) event { if([Touch tapcount] = = 1) { nslog,[imageview image); uiimagewritetosavedphotosalbum ([imageview image], nil, nil, Nil uialertview *alert = [[uialertview alloc] initwithtitle:@ "store photos successfully " message:@ "you have saved your photos in a picture library, you can view them by opening the photo program." " delegate: Self cancelbuttontitle:@ "OK" otherbuttontitles:nil]; [Alert show]; [Alert release]; } } |
Description
Uiimagewritetosavedphotosalbum is a function in the Uikit framework. Here's what the following three parameters mean: void Uiimagewritetosavedphotosalbum ( UIImage *image, ID Completiontarget, SEL Completionselector, void *contextinfo ); The ID is the target object, and thesel is selector, the method name on the target object, andContextInfo is any pointer that is passed to the selector defined method. This is usually done when the method is called when it is finished, or when the error is completed. |
Save to album