【发布时间】:2016-11-06 18:55:49
【问题描述】:
我正在快速运行示例应用程序。我需要从我的应用程序共享图像。
在Social framework 的帮助下,我整合了Facebook 和Twitter。现在我不知道如何与Instagram 和WhatsApp 集成
分享按钮操作
@IBAction func shareAcn(sender: UITapGestureRecognizer) {
var documentController: UIDocumentInteractionController!
let fileURL = NSBundle.mainBundle().pathForResource("smc", ofType: "png")
documentController = UIDocumentInteractionController.init(URL: NSURL(fileURLWithPath: fileURL!))
documentController.presentOptionsMenuFromRect(CGRectZero, inView: self.view, animated: true)
}
@IBAction func shareAcn(sender: UITapGestureRecognizer) {
var documentController: UIDocumentInteractionController!
let image = UIImage(named: "smc")
let filename = "myimage.wai"
let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, false)[0] as NSString
let destinationPath = documentsPath.stringByAppendingString("/" + filename)
UIImagePNGRepresentation(image!)!.writeToFile(destinationPath, atomically: false)
let fileURL = NSURL(fileURLWithPath: destinationPath) as NSURL
documentController = UIDocumentInteractionController.init(URL: fileURL)
documentController.UTI = "net.whatsapp.image"
documentController.presentOptionsMenuFromRect(CGRectZero, inView: self.view, animated: true)
}
如果我选择 [导入到 WhatsApp 或复制到 WhatsApp] 应用程序崩溃。如果我选择WhatsApp,“此项目无法发送”。
var instagramURL: NSURL = NSURL(string: "instagram://user?username=USERNAME")
if UIApplication.sharedApplication().canOpenURL(instagramURL) {
UIApplication.sharedApplication().openURL(instagramURL)
}
没有代码在工作。
我安装了Instagram 并以我的用户身份登录我的测试设备,如果我运行,Instagram 没有打开。
不知道怎么解决?请指导我。
【问题讨论】:
-
LSApplicationsQueriesSchemes ??它在 Info.plist 中的什么位置?我查不出来。
-
如果你在 if 语句中放了一个断点,它会命中它吗?
-
其他部分一直在工作??
-
@shallowThought 如果你知道答案,请告诉我?我到处都是serchin..但不理解概念..请
标签: swift instagram whatsapp uidocumentinteraction