如何使用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 })