"Learn iOS: UI series" To save a picture to a photo album that comes with iOS

Source: Internet
Author: User

Specific features:

There is a uiimageview in one view, and when you press and hold Uiimageview, the picture represented by UIImage in Uiimageview is saved to PhotoAlbum.


Implementation: The code is as follows: Self.imageview is a defined Uiimageview view property

Long press Effect-(void) longpangesture {    Uilongpressgesturerecognizer *longgesture = [[Uilongpressgesturerecognizer alloc] Initwithtarget:self                                                               </span>action: @selector (longpangesture:)];    [Self.imageview addgesturerecognizer:longgesture];    Longgesture.minimumpressduration = 4;    [Longgesture release];}
Corresponding event: Longpangesture method implementation

-(void) Longpangesture: (Uilongpressgesturerecognizer *) longgesture {    if (longgesture.state = = Uigesturerecognizerstatebegan) {        uiimagewritetosavedphotosalbum ([Self.imageview image], nil, nil,nil);        Uialertview *alert = [[Uialertview alloc] initwithtitle:@ "Save photos successfully"                              message:@ "photos are stored in picture library" Delegate:self cancelbuttontitle:@ "OK" otherbuttontitles:nil];        [Alert show];        [Alert release];}    }
Uiimagewritetosavedphotosalbum method

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);/**id is the target object *sel is selector. The name of the method on the target object * ContextInfo is an arbitrary pointer that is passed to the method defined by the selector. * This is usually done when the method is called when it is finished, or when it is completed with an error. */

Original: Address

"Learn iOS: UI series" To save a picture to a photo album that comes with iOS

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.