ios8 Extension之分享

下图为iPhone/iOS8中的【照片】分享:xcode

1.首先建立工程,在咱们的工程中新建一个Target:xcode->File->new->target
动画

以后,模板中会为咱们建立一个controller类,这个controller用于控制咱们的分享插件spa

一些经常使用的属性:.net

- (void)presentationAnimationDidFinish;插件

弹出视图动画结束后执行的方法code

@property (readonly, NS_NONATOMIC_IOSONLY) NSString *contentText;文档

分享的内容文字get

@property (copy, NS_NONATOMIC_IOSONLY) NSString *placeholder;it

默认显示的提示文字io

- (void)didSelectCancel;

取消按钮执行的方法

咱们在代码中以下添加后运行

-(NSString *)placeholder{
     return  @ "提示文字" ;
}
- (NSArray *)configurationItems {
     // To add configuration options via table cells at the bottom of the sheet, return an array of SLComposeSheetConfigurationItem here.
     SLComposeSheetConfigurationItem * item =[[SLComposeSheetConfigurationItem alloc]init];
     item.title=@ "地点" ;
     item.value=@ "城门" ;
     return  @[item];

}

点击more就能够看到了

还有一点咱们须要了解,在这个扩展的plist文件中,有这样一个键:NSExtensionAttributes,里面有一个NSExtensionActivationRule的字典,其中能够设置一些键值,对分享插件的属性进行控制。


这些键的写法在官方文档中的介绍以下:

这些键的意义,文档中介绍的很清楚,咱们能够根据须要进行设置。

相关文章
相关标签/搜索