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

最佳答案

这是从事件 Controller 共享文本和url 的代码

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 })

关于ios - 带有UIActivityViewController的WhatsApp可以不使用UIDocumentInteractionController共享图像,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23366324/

10-10 09:54