//设置分享的内容
NSString* text =@"分享内容";
//UIImage * image = [UIImage imageNamed:@""];
//NSURL * url = [NSURL URLWithString:@"https://www.baidu.com"];
//数组中存放分享的内容
NSArray* activityItems =@[text];
//实现服务类型控制器
UIActivityViewController* activityViewController = [[UIActivityViewControlleralloc]initWithActivityItems:activityItemsapplicationActivities:nil];
[selfpresentViewController:activityViewControlleranimated:YEScompletion:nil];
//分享的类型
[activityViewControllersetCompletionWithItemsHandler:^(NSString*__nullableactivityType,BOOLcompleted,NSArray*__nullablereturnedItems,NSError*__nullableactivityError){
//显示选中的分享类型
NSLog(@"当前选择分享平台%@",activityType);
if(completed) {
NSLog(@"分享成功");
}else{
NSLog(@"分享失败");
}
}];