Save to album

Source: Internet
Author: User

@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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.