gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 09:22:15 25 4
gpt4 key购买 nike

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)
}
}
分享菜单:
enter image description here
Instagram错误:
enter image description here

最佳答案

我为此苦苦挣扎,最终使用了 UIActivityViewController 并且它起作用了。

 let items = [image]
let ac = UIActivityViewController(activityItems: items, applicationActivities: nil)
present(ac, animated: true)

关于ios - Instagram 分享到 Feed iOS 不起作用 (UIDocumentInteractionController),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65003868/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com