IOS8 new feature extension (Extension) Application II-Share plugin

Source: Internet
Author: User

IOS8 new feature extension (Extension) Application II-Share plugin

in the previous blog, we introduced the Today feature of IOS8, one of the features of the new feature extension: http://my.oschina.net/u/2340880/blog/485533, where we'll look at the extended functionality of sharing.

Before iOS8, in addition to some of the mainstream social platforms, such as Apple's support for content sharing, other developers ' apps would be very complex to add to the shared functionality. In the new features of IOS8, Apple has prepared such extensions for us.

Start by creating a project and create a new target in our project:


After that, a controller class is created for us in the template that controls our share plugin, which includes:

@implementation  shareviewcontroller//This function is used to determine the availability of shared content, in which we get shared content to check-  (BOOL) iscontentvalid {     // Do validation of contentText and/or  Nsextensioncontext attachments here    return yes;} After clicking the Post button, we can upload the contents of the-  (void) didselectpost {    // this  is called after the user selects Post. Do the upload  of contenttext and/or nsextensioncontext attachments.         // inform the host that we ' Re done, so it un-blocks  its ui. note: alternatively you could call super ' s - didselectpost, which will similarly complete the extension context.     [self.extensioncontext completerequestreturningitemS:@[] completionhandler:nil];} This is used to set the share plugin's attachment button-  (nsarray *) Configurationitems {    // to add  configuration options via table cells at the bottom of the  sheet, return an array of SLComposeSheetConfigurationItem here.     return @[];} @end

In addition, there are some common properties:

-(void) presentationanimationdidfinish;

Methods to execute after the pop-up view animation finishes

@property (readonly, ns_nonatomic_iosonly) NSString *contenttext;

Content text to share

@property (copy, ns_nonatomic_iosonly) NSString *placeholder;

Prompt text displayed by default

-(void) didselectcancel;

How to cancel a button execution

We'll run it in the code after adding the following:

@implementation shareviewcontroller-(NSString *) placeholder{return @ "hint text";}  -(Nsarray *) Configurationitems {//To add configuration options via table cells in the bottom of the sheet, return an    Array of Slcomposesheetconfigurationitem here.    Slcomposesheetconfigurationitem * Item =[[slcomposesheetconfigurationitem Alloc]init];    [Email protected] "location";    [Email protected] "Shing Mun"; return @[item];}

We use the System photo album to do the test, click the photo sharing button:


Click More to add our extensions.


Then there is one more of our plugin in the Sharing bar, click the effect as follows:



There is one more thing we need to understand, in this extended plist file, there is a key: Nsextensionattributes, there is a nsextensionactivationrule dictionary, where you can set some key values, Controls the properties of the share plugin.


The wording of these keys is described in the official documentation as follows:


The meanings of these keys are clearly described in the documentation and can be set as needed.

IOS8 new feature extension (Extension) Application II-Share 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.