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)