IOS8 new feature extension (Extension) application three--Photo editor Plugin

Source: Internet
Author: User

IOS8 new feature extension (Extension) application three--Photo editor Plugin

with the introduction of the previous blogs, we learned that the extended interactive capabilities offered by the app are more powerful, and this powerful interactivity is reflected in the application of the photo editing plugin.

As usual, let's create a project and then a new target, select photo editing:

From the template, we can see that the system has created a controller for us, which is the controller used to process the photo, with the following methods:

-  (BOOL) Canhandleadjustmentdata: (phadjustmentdata *) adjustmentdata {    //  Inspect the adjustmentData to determine whether your extension  can work with past edits.    //  (Typically, you use  its formatidentifier and formatversion properties to do this.)     return no;} This function is used to get the selected photo from the system album, the data type that contains the response in the Contenteditinginput object, and the image object-  (void) Startcontenteditingwithinput: ( phcontenteditinginput *) Contenteditinginput placeholderimage: (uiimage *) placeholderImage {    //we can get the data to show here and so on     self.input = contenteditinginput;} Method-  (void) Finishcontenteditingwithcompletionhandler when editing a photo: (void  (^) (phcontenteditingoutput  *)) completionhandler {    // update ui to reflect that editing has finished and output is being rendered.         // Render and provide output on a  Background queue.    dispatch_async (Dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY _default, 0), ^{        // create editing  output from the editing input.         phcontenteditingoutput *output = [[phcontenteditingoutput alloc]  initwithcontenteditinginput:self.input];                 //we can write new picture data into the output stream here         //  output.adjustmentdata = < #new  adjustment data#>;         // nsdata *renderedjpegdata = < #output  JPEG#>;        // [renderedJPEGData  writetourl:output.renderedcontenturl atomically:yes];                 // call completion handler to commit  edit to photos.        completionhandler (output);                 // clean  up temporary files, etc.    });}

Before the end of the current extension execution, we are free to render the images we get, such as adding frames, text, etc., and outputting the rendered image after the output.

There's another place we need to be aware that this kind of extension has a function, if we exit the editor halfway, the system will save our extended processing state for us, in order to distinguish multiple similar functions of the extension, in the output data of the object has a An object of type Phadjustmentdata that is dedicated to the record of the version, which has the following two attributes to differentiate the version:

@property (readonly, copy) nsstring *formatidentifier;

@property (readonly, copy) nsstring *formatversion;




IOS8 new feature extension (Extension) application three--Photo editor Plugin

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.