与Instagram,Facebook的相机分享图像
问题描述:
我有一个AR应用程序,使用ARKit开发xcode 9。我有一个按钮,它会截取用户视图的截图,并将图像保存到照片中(相机胶卷)。与Instagram,Facebook的相机分享图像
现在我想有一个分享按钮,让用户分享拍摄存储在相机中的角色最后的图像与Facebook,微博,Instagram的等等
分享,我想我使用“UIActivityViewController “功能,但我不知道如何传递最后拍摄的图像以与所选应用程序共享。
有关如何编码的任何想法?
答
,当你把屏幕的截图,你可以直接传递到的UIImage UIActivityViewController
// to create an image from screenshot
UIGraphicsBeginImageContext(view.frame.size)
view.layer.renderInContext(UIGraphicsGetCurrentContext())
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
// to share the image
var imagesToShare = [AnyObject]()
imagesToShare.append(image)
let activityViewController = UIActivityViewController(activityItems: imagesToShare , applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.view
presentViewController(activityViewController, animated: true, completion: nil)
谢谢!一个问题,但;我如何获得它分享存储在手机相机胶卷上的最后一张照片,而不是截取当前帧的截图? –