通常在做分享的时候 都会去集成第三方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);
};
效果如下
WechatIMG7.jpeg WechatIMG8.jpeg WechatIMG9.jpeg
网友评论