0

目前与 Instagram 和集成存在问题。UIDocumentInteractionController 不显示任何带有 instagram 的图标,并且无法直接在 Instagram 上发布内容。

    func shareToInstagramFeed(image: UIImage) {
        guard let instagramUrl = URL(string: "instagram://app") else {
            return
        }

        if UIApplication.shared.canOpenURL(instagramUrl) {
            guard let imageData = image.jpegData(compressionQuality: 100) else {
                return
            }

            let path = (NSTemporaryDirectory() as NSString).appendingPathComponent("instagram.ig")
            let fileUrl = URL(fileURLWithPath: path)

            do {
                try imageData.write(to: fileUrl, options: .atomic)
            } catch {
                return
            }
            
            let documentController = UIDocumentInteractionController()
            documentController.delegate = self
            documentController.uti = "com.instagram.photo"
            documentController.url = fileUrl
            
            documentController.presentOpenInMenu(from: self.view.frame, in: self.view, animated: true)
        } else {
        }
    }
4

0 回答 0