使用UIActivityViewController的WhatsApp不使用UIDocumentInteractionController来共享图像

时间:2014-04-29 13:38:43

标签: ios ios7 whatsapp

如何使用UIActivityViewController设置 WhatsApp 来共享图片,而不是使用UIDocumentInteractionController。如果有其他方法,请告诉我。提前谢谢。

2 个答案:

答案 0 :(得分:5)

这是从活动控制器

分享 文字和网址 的代码
NSString *URLString=@"http://video.app.com/video.php?";

NSURL *VideoURL=[NSURL URLWithString:URLString];

NSMutableArray *activityItems= [NSMutableArray arrayWithObjects:VideoURL, @"Hey, check out this video I've shared with you, it's awesome!", nil];

self.activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
self.activityViewController.excludedActivityTypes = @[UIActivityTypePostToWeibo,UIActivityTypePrint,
                                                      UIActivityTypeCopyToPasteboard,UIActivityTypeAssignToContact,
                                                      UIActivityTypeSaveToCameraRoll,UIActivityTypeAddToReadingList,
                                                      UIActivityTypePostToFlickr,UIActivityTypePostToVimeo,
                                                      UIActivityTypePostToTencentWeibo,UIActivityTypeAirDrop];

[self presentViewController:self.activityViewController animated:YES completion:nil];

适用于Swift 3.0

let objectsToShare = ["\(Title) \n \(Description)"]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
activityVC.setValue("App Name", forKey: "subject")

let excludeActivities = [UIActivityType.airDrop, UIActivityType.print, UIActivityType.assignToContact, UIActivityType.saveToCameraRoll, UIActivityType.addToReadingList, UIActivityType.postToFlickr, UIActivityType.postToVimeo, UIActivityType.postToFacebook, UIActivityType.message, UIActivityType.postToWeibo]
activityVC.excludedActivityTypes = excludeActivities

self.present(activityVC, animated: true, completion: { _ in })

答案 1 :(得分:1)

尝试在官方WhatsApp网站上描述的URL方案方法:

https://www.whatsapp.com/faq/iphone/23559013