ios – 带有UIActivityViewController的WhatsApp,用于不使用UIDocumentInteractionController共享图像

前端之家收集整理的这篇文章主要介绍了ios – 带有UIActivityViewController的WhatsApp,用于不使用UIDocumentInteractionController共享图像前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何使用UIActivityViewController设置WhatsApp以共享图像,而不是使用UIDocumentInteractionController.如果有其他方法,请告诉我.提前致谢.

解决方法

这是从活动控制器共享文本和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 })
原文链接:https://www.f2er.com/iOS/328387.html

猜你在找的iOS相关文章