美文网首页
UIActivityViewController原生分享 微信文

UIActivityViewController原生分享 微信文

作者: kadis | 来源:发表于2024-04-22 14:19 被阅读0次

通常在做分享的时候 都会去集成第三方SDK,友盟、极光等,需要花费一些时间,其实系统也自带了分享的控件给我们,今天主要记录之前使用UIActivityViewController微信分享不能title 图片 URL 并存的问题
NSMutableArray *items = [[NSMutableArray alloc] init];
[items addObject:@"我是title啊"];
//这里是一张本地的图片
[items addObject:[UIImage imageNamed:@"1"]];
//这里不要直接写URL 否则微信会显示不识别
[items addObject:[NSURL URLWithString:@"http://www.jianshu.com/u/072ec5eabc75"]];

UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil];

//这个数组里面写你不想被现实出来的
//NSMutableArray *excludedActivityTypes = [NSMutableArray arrayWithArray:@[UIActivityTypeAirDrop, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact, UIActivityTypePrint, UIActivityTypeMail, UIActivityTypePostToTencentWeibo, UIActivityTypeSaveToCameraRoll, UIActivityTypeMessage, UIActivityTypePostToTwitter]];
//activityViewController.excludedActivityTypes = excludedActivityTypes;
[self presentViewController:activityViewController animated:YES completion:nil];
activityViewController.completionWithItemsHandler = ^(UIActivityType __nullable activityType, BOOL completed, NSArray * __nullable returnedItems, NSError * __nullable activityError){
NSLog(@"%@ ---- %@", activityType, returnedItems);
};

相关文章

网友评论

      本文标题:UIActivityViewController原生分享 微信文

      本文链接:https://www.haomeiwen.com/subject/fuabxjtx.html