2016-07-01 20 views
1

我无法在我的iOS应用程序上分享脸书上的链接。 我正在使用下面的代码,它在几个月前工作。 我以前做的,唯一设置为“进口社会Swift share on facebook

@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共享对话框,但它不包含任何链接。 有人知道它改变了什么?

+0

你可以截图吗? – Proton

回答

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"