【问题标题】:Swift share on facebook迅速在脸书上分享
【发布时间】:2016-07-01 12:22:46
【问题描述】:

我无法通过我的 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 分享对话框,但它不包含任何链接。 有谁知道它改变了什么?

【问题讨论】:

  • 可以截图吗?

标签: xcode swift facebook share facebook-share


【解决方案1】:

替换这一行

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

有了这个

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

考虑到您想要分享网址 - "https://www.xxx.ro/info/article/xid"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-08-03
    • 1970-01-01
    • 2011-12-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-28
    • 1970-01-01
    相关资源
    最近更新 更多