NSArray*activityItems ;
if( [str_SelectURLhasSuffix:@".png"])
{
UIImage*imageToShare = [UIImageimageNamed:str_SelectURL];
activityItems =@[imageToShare];
}else
{
NSURL*shareURL = [NSURLfileURLWithPath:str_SelectURL];
activityItems=@[shareURL];
}
UIActivityViewController *avc = [[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil];
[self presentViewController:avc animated:YES completion:nil];
[avcsetCompletionWithItemsHandler:^(NSString*__nullableactivityType,BOOLcompleted,NSArray*__nullablereturnedItems,NSError*__nullableactivityError){
// 显示选中的分享类型
NSLog(@"act type %@",activityType);
//结果
if(completed) {
MBProgressHUD*hud = [MBProgressHUDshowHUDAddedTo:self.viewanimated:YES];
hud.label.text= [NSStringstringWithFormat:@"%@",CustomLocalizedString(@"Share_Success",nil)];
dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{
sleep(2);
dispatch_async(dispatch_get_main_queue(), ^{
[hudhideAnimated:YES];
});
});
}else{
MBProgressHUD*hud = [MBProgressHUDshowHUDAddedTo:self.viewanimated:YES];
hud.label.text= [NSStringstringWithFormat:@"%@",CustomLocalizedString(@"Share_Fail",nil)];
dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{
sleep(2);
dispatch_async(dispatch_get_main_queue(), ^{
[hudhideAnimated:YES];
});
});
}
}];