【问题标题】:iOS10 swift 2.2 share on Instagram openURL& canOpenURL changeiOS10 swift 2.2 分享在Instagram openURL& canOpenURL 更改
【发布时间】:2016-09-26 16:21:38
【问题描述】:

我正在使用swift 2.2将照片分享到Instagram的功能,它适用于iOS9但在iOS10上失败,iOS9和iOS10有什么区别吗? 这是我在iOS9上实现它的方法,感谢您的任何建议。

class viewController: UIViewController, UIDocumentInteractionControllerDelegate {

var yourImage: UIImage?
var documentController: UIDocumentInteractionController!

func shareToInstagram() {

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

        if (UIApplication.sharedApplication().canOpenURL(instagramURL!)) {

            let imageData = UIImageJPEGRepresentation(yourImage!, 100)

            let captionString = "caption"

       let writePath = (NSTemporaryDirectory() as NSString).stringByAppendingPathComponent("instagram.igo")
       if imageData?.writeToFile(writePath, atomically: true) == false {

                return

            } else {
 let fileURL = NSURL(fileURLWithPath: writePath)

                self.documentController = UIDocumentInteractionController(URL: fileURL)

                self.documentController.delegate = self

                self.documentController.UTI = "com.instagram.exlusivegram"

                self.documentController.annotation = NSDictionary(object: captionString, forKey: "InstagramCaption")
                      self.documentController.presentOpenInMenuFromRect(self.view.frame, inView: self.view, animated: true)

            }

        } else {
            print(" Instagram isn't installed ")
        }
    }

【问题讨论】:

  • 它是怎么失败的?你有错误吗?它会默默地失败吗?
  • 嗨 @NicolasMiari,当我尝试在 iOS 10 设备上将照片分享到 Instagram 时,它只是没有响应。是的,它默默地失败了,之后应用程序仍在工作。

标签: swift ios9 instagram ios10 url-scheme


【解决方案1】:

问题已解决,只需更新到 xcode8 并使用 swift2.3。

【讨论】:

    猜你喜欢
    • 2016-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-04
    • 2017-03-19
    • 2019-04-30
    相关资源
    最近更新 更多