//分享的标题
NSString *textToShare = @"标题";
//分享的图片
UIImage *imageToShare = [UIImage imageNamed:@"logo.png"];
//分享的url
NSURL *urlToShare = [NSURL URLWithString:@"http://www.baidu.com"];
NSArray *activityItems = @[textToShare,imageToShare, urlToShare];
UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil];
activityVC.excludedActivityTypes = @[UIActivityTypePrint, UIActivityTypeCopyToPasteboard,UIActivityTypeAssignToContact,UIActivityTypeSaveToCameraRoll];
[self presentViewController:activityVC animated:YES completion:nil];
//分享之后的回调
activityVC.completionWithItemsHandler = ^(UIActivityType _Nullable activityType, BOOL completed, NSArray * _Nullable returnedItems, NSError * _Nullable activityError) {
if (completed) {
NSLog(@"completed");
//分享 成功
} else {
NSLog(@"cancled");
//分享 取消
}
};
网友评论