//設(shè)置分享的內(nèi)容
NSString* text =@"分享內(nèi)容";
//UIImage * image = [UIImage imageNamed:@""];
//NSURL * url = [NSURL URLWithString:@"https://www.baidu.com"];
//數(shù)組中存放分享的內(nèi)容
NSArray* activityItems =@[text];
//實現(xiàn)服務(wù)類型控制器
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(@"分享失敗");
}
}];