The Share Button is Invalid/Disabled
嘿伙计们,
所以我尝试在我的个人应用程序开发中使用Facebook SDK,它使用了swift 3。但是,当我尝试使用Share按钮时,它总是以灰色背景禁用,并且我不知道在浏览了Facebook SDK文档和引用之后应该更改什么。
有人知道怎么解决吗?以下是我如何编写共享按钮:

let shareButton = ShareButton(frame: CGRect(x: 50.0, y: 25.0, width: 200, height: 40), content: (LinkShareContent(url: URL(string: "theURLAddress")!)))
view.addSubview(shareButton)

最佳答案

Objective-C软件开发包:
将Facebook SDK更新为最新版本(v4.x),并使用以下代码:

let shareButton = FBSDKShareButton(frame: CGRect(x: 50.0, y: 25.0, width: 200, height: 40))
let content = FBSDKShareLinkContent()
content.contentURL = URL(string: "theURLAddress")
content.quote = "some quote "
shareButton.shareContent = content
self.view.addSubview(shareButton)

Swift软件开发工具包:
使用swift SDK时,请使用以下代码和真实的URL而不是假的URL。
let shareButton = ShareButton<LinkShareContent>()
let content = LinkShareContent(url: URL(string: "https://stackoverflow.com/a/45263496/1724845")!)
shareButton.content = content
shareButton.frame = CGRect(x: 50.0, y: 25.0, width: 200, height: 40)
view.addSubview(shareButton)

07-27 19:27