xcode - 在 Facebook 上快速分享

标签 xcode swift facebook share facebook-share

我无法通过我的 iOS 应用程序在 Facebook 上分享链接。 我正在使用下面的代码,它在几个月前就开始工作了。 我曾经做的唯一设置是“import Social

@IBAction func facebookShareButtonTouched(sender: AnyObject) {
    if SLComposeViewController.isAvailableForServiceType(SLServiceTypeFacebook) {
        let fbShare:SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeFacebook)

        fbShare.addURL(NSURL(fileURLWithPath: "https://www.xxx.ro/info/article/\(newsObject.id!)"))
        self.presentViewController(fbShare, animated: true, completion: nil)


    } else {
        let alert = UIAlertController(title: "Accounts", message: "Please login to a Facebook account to share.", preferredStyle: UIAlertControllerStyle.Alert)


        alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
        self.presentViewController(alert, animated: true, completion: nil)
    }
}

现在它打开了 facebook 共享对话框,但它不包含任何链接。 有人知道它改变了什么吗?

最佳答案

替换这一行

fbShare.addURL(NSURL(fileURLWithPath: "https://www.xxx.ro/info/article/\(newsObject.id!)"))

有了这个

fbShare.addURL(NSURL("https://www.xxx.ro/info/article/\(newsObject.id!)"))

回答考虑到你想要分享 URL - “https://www.xxx.ro/info/article/xid”

关于xcode - 在 Facebook 上快速分享,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38145375/

相关文章:

ios - iOS 8 应用程序/框架中缺少必需的模块 'CocoaLumberjack'

java - 用于发布到粉丝页面的 Facebook 应用程序

php - 与 Session 相关的 Facebook token

swift 声明一个常量而不让

arrays - Swift - 将结构数组传递给另一个结构的初始化

android - Android 的 Facebook key 哈希为所有用户启用

xcode - 无法构建 iOS 应用程序错误输出来自 Xcode 构建 :

ios - 如何警告调用者 Swift 中的函数

iOS mapView animatesDrop

ios - 从新的 Storyboard实例化 ViewController