iOS.在不使用菜单显示的情况下将图像共享到Instagram [英] IOS. Sharing image to Instagram without using a menu display

查看:133
本文介绍了iOS.在不使用菜单显示的情况下将图像共享到Instagram的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以在不显示菜单的情况下帮助并解释如何与Instagram共享吗?例如,应用程序Prisma无需使用菜单显示即可完成操作.

Can anyone help and explain how to do sharing to Instagram without displaying the menu? For example, the application Prisma does it without using a menu display.

推荐答案

您必须执行以下操作:

  1. 将照片保存到照片库
  2. 获取已保存照片的资产网址
  3. 通过具有该URL的URL方案打开Instagram

instagram://library?AssetPath = ASSET_PATH

instagram://library?AssetPath=ASSET_PATH

其中ASSET_PATH是第二步中获取的资产网址.

Where ASSET_PATH is asset url taken on the second step.

Swift 3 上的代码示例:

let library = ALAssetsLibrary()
library.writeImage(toSavedPhotosAlbum: image.cgImage, metadata: nil) { (url, error) in
    if let url = url {
        DispatchQueue.main.async {
            let path = url.absoluteString.addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlQueryAllowed)
            let instagram = URL(string: "instagram://library?AssetPath=\(path)")
            UIApplication.shared.open(instagram!)
        }
    }
}

这篇关于iOS.在不使用菜单显示的情况下将图像共享到Instagram的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆