Ios 如何将Instagram活动添加到UIActivityViewController
我无法找到将Instagram选项添加到UIActivityViewController的解决方案。有人能帮忙吗。谢谢Ios 如何将Instagram活动添加到UIActivityViewController,ios,swift,instagram,uiactivityviewcontroller,Ios,Swift,Instagram,Uiactivityviewcontroller,我无法找到将Instagram选项添加到UIActivityViewController的解决方案。有人能帮忙吗。谢谢 使用类似以下内容: @IBAction func shareOnIntagram(sender: UIButton) { let finalImage: UIImage = UIImage.imageWithView(photoView) let instagramURL = NSURL(string: "instagram://app") if (U
使用类似以下内容:
@IBAction func shareOnIntagram(sender: UIButton) {
let finalImage: UIImage = UIImage.imageWithView(photoView)
let instagramURL = NSURL(string: "instagram://app")
if (UIApplication.sharedApplication().canOpenURL(instagramURL!)) {
let imageData = UIImageJPEGRepresentation(finalImage, 1)
let captionString = "caption"
let writePath = (NSTemporaryDirectory() as NSString).stringByAppendingPathComponent("instagram.ig")
if imageData?.writeToFile(writePath, atomically: true) == false {
return
} else {
let fileURL = NSURL(fileURLWithPath: writePath)
self.documentController = UIDocumentInteractionController(URL: fileURL)
self.documentController.delegate = self
self.documentController.UTI = "com.instagram.photo"
self.documentController.annotation = NSDictionary(object: captionString, forKey: "InstagramCaption")
self.documentController.presentOpenInMenuFromRect(self.view.frame, inView: self.view, animated: true)
}
} else {
print(" Instagram is not installed ")
}
}
要使此代码正常工作,请不要忘记在UIViewController类中添加
UIDocumentInteractionControllerDelegate
。发布您尝试过的代码。我尝试过将图像添加到照相/摄像机中的代码,然后打开Instagram应用程序。但是我在UIActivityViewController中找不到任何相关的代码。你找到解决方案了吗?我也面临同样的问题,我不知道该怎么办。我已经试过代码了。如果安装了instagram应用程序,它将打开instagram应用程序,而不显示UIActivityViewController。答案与所问的相差甚远。