Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用Swift中的UIDocumentInteractionController向Instagram应用程序发布多张照片_Ios_Swift_Instagram - Fatal编程技术网

Ios 使用Swift中的UIDocumentInteractionController向Instagram应用程序发布多张照片

Ios 使用Swift中的UIDocumentInteractionController向Instagram应用程序发布多张照片,ios,swift,instagram,Ios,Swift,Instagram,我是经验丰富的开发人员,但对Swift是新手。 我的目的是以编程方式在iOS应用程序中绘制一些图像,并将它们发布到Instagram应用程序中 经过一些研究,我发现以下两种方法可以做到这一点 第一个是UIActivityViewController。这种方式可以很好地处理一张图片,但当我通过两张或更多图片时,Instagram应用程序不会显示在popover视图中 第二种方法是使用UIDocumentInteractionController。通过这种方式,我可以将图像路径作为URL传递。但是使

我是经验丰富的开发人员,但对Swift是新手。 我的目的是以编程方式在iOS应用程序中绘制一些图像,并将它们发布到Instagram应用程序中

经过一些研究,我发现以下两种方法可以做到这一点

第一个是UIActivityViewController。这种方式可以很好地处理一张图片,但当我通过两张或更多图片时,Instagram应用程序不会显示在popover视图中

第二种方法是使用UIDocumentInteractionController。通过这种方式,我可以将图像路径作为URL传递。但是使用这个URL,我只能向类传递一个图像路径。我的代码如下

    let instagramURL = NSURL(string: "instagram://app")


    if(UIApplication.shared.canOpenURL(instagramURL! as URL)) {
        let imagePost = imageToPost

        let fullPath = NSURL(fileURLWithPath: documentsDirectory()).appendingPathComponent("insta.igo")
        let a = try! UIImagePNGRepresentation(imagePost)?.write(to: fullPath!, options: .atomic)

        let rect = CGRect(x: 0, y: 0, width: 0, height: 0)
        self.docController.uti = "com.instagram.exclusivegram"
        let igImageHookFile = fullPath
        self.docController = UIDocumentInteractionController(url: igImageHookFile! as URL)
        self.docController.annotation = ["InstagramCaption":"Text"]
        self.docController.presentOpenInMenu(from: rect, in: self.view, animated: true)

    } else {
        print("no instagram found")
    }

有没有办法不使用照相胶卷就发布多张图像?

您好,您有什么发现吗?我还想在不使用照相胶卷的情况下发布多张图片。不完全是这样。我认为这是不可能的,因为Instagram应用程序不支持这一点。嗨,你有什么发现吗?我还想在不使用照相胶卷的情况下发布多张图片。不完全是这样。我认为这是不可能的,因为Instagram应用程序不支持这一点。