栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

将Instagram添加到UIActivityViewController

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

将Instagram添加到UIActivityViewController

我认为将其他社交共享添加到您为Instagram编写的代码中会更加容易。“
.igo”扩展名是Instagram专有的,因此其他应用程序将不支持它。只需将此扩展名从“ .igo”更改为“ .ig”,其他应用程序就会读取它:

var savePath: String = NSHomeDirectory().stringByAppendingPathComponent("documents/Test.ig")

但是Instagram还具有专有的UTI,可避免其他应用程序出现在同一文档交互视图中。因此,您还需要将其从“独占图”更改为“照片”:

docController.UTI = "com.instagram.photo"

我有一个具有类似功能的应用,这是我的原始代码:

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

为了使此代码正常工作,请不要忘记添加

UIdocumentInteractionControllerDelegate
UIViewController类。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/616402.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号