Today to do chat, the leader said each other to send me a picture, I want to save to the local, iOS Uikit framework provides the Uiimagewritetosavedphotosalbum method to save the image, the method will save image to the user's album:
On the code:
void uiimagewritetosavedphotosalbum ( UIImage *image, ID Completiontarget, SEL completionselector, void *contextinfo );
Parameter description:
Image: A picture object that needs to be saved
ID: Response Method Object
SEL: Selection method
Steps:
/* * * */-(void) addimageviewtolocal{*data = [NSData datawithcontentsofurl:[nsurl Urlwithstring:_currentitem.imageurl]]; *myimage = [UIImage imagewithdata:data]; [Self saveimagetophotos:myimage]; }
Step Two:
-(void) Saveimagetophotos: (uiimage*) savedimage{ uiimagewritetosavedphotosalbum (Savedimage, Self, @selector (image:didFinishSavingWithError:contextInfo:), NULL); }
Step Three:
- (voidImage: (UIImage *) image didfinishsavingwitherror: (nserror *) Error ContextInfo: (void*) contextinfo{NSString*msg =Nil; if(Error! =NULL) {msg=@"failed to save picture" ; }Else{msg=@"Save Picture Success" ; } Uialertview*alert = [[Uialertview alloc] Initwithtitle:@"Save picture result hint"message:msg Delegate: Self cancelbuttontitle:@"Determine"Otherbuttontitles:nil]; [Alert show];}
This allows the image to be saved to a local album;
ios--saving Pictures to a local album