小编Boh*_*zov的帖子

Instagram 分享到 Feed iOS 不起作用 (UIDocumentInteractionController)

iOS 14.2,我无法按照https://developers.facebook.com/docs/instagram/sharing-to-feed/ 中的描述共享图像

我可以从这个菜单正确地将相同的图像分享给任何其他应用程序(例如电报)

代码:

func shareToInstagramFeed() {
    let instagramURL = NSURL(string: "instagram://")

    if UIApplication.shared.canOpenURL(instagramURL! as URL) {
        let jpgPath = (NSTemporaryDirectory() as NSString).appendingPathComponent("instagram.ig")
        do {
            try selectedImage.image?.jpegData(compressionQuality: 1)?.write(to: URL(fileURLWithPath: jpgPath), options: .atomic)
        } catch {
            print(error)
        }
        let rect = CGRect.zero
        
        documentInteractionController = UIDocumentInteractionController(url: URL(fileURLWithPath: jpgPath))
        documentInteractionController.delegate = self
        documentInteractionController.uti = "com.instagram.photo"
        documentInteractionController.presentOpenInMenu(from: rect, in: view, animated: true)
    }
}
Run Code Online (Sandbox Code Playgroud)

分享菜单: 在此处输入图片说明

Instagram错误: 在此处输入图片说明

facebook ios instagram swift

8
推荐指数
1
解决办法
287
查看次数

标签 统计

facebook ×1

instagram ×1

ios ×1

swift ×1