我是 iOS 新手,我想分享一个使用 Facebook SDK for iOS 的链接。我的代码如下:
@IBAction func shareVoucherUsingFacebook(sender: UIButton) {
print("Facebook")
let content : FBSDKShareLinkContent = FBSDKShareLinkContent()
content.contentURL = NSURL(string: "www.google.com")
content.contentTitle = "Content Title"
content.contentDescription = "This is the description"
let shareDialog: FBSDKShareDialog = FBSDKShareDialog()
shareDialog.shareContent = content
shareDialog.delegate = self
shareDialog.fromViewController = self
shareDialog.show()
}
我还实施了FBSDKSharingDelegate
方法,但是当我按此按钮时无法收到共享对话框,并且该方法func sharer(sharer: FBSDKSharing!, didFailWithError error: NSError!)
正在执行,这意味着出了问题,但我无法弄清楚。
提前致谢。
改变这条线
content.contentURL = NSURL(string: "www.google.com")
into
content.contentURL = NSURL(string: "https:\\www.google.com")
和我一起工作
这是我使用的委托方法
func sharer(sharer: FBSDKSharing!, didCompleteWithResults results: [NSObject: AnyObject])
{
print(results)
}
func sharer(sharer: FBSDKSharing!, didFailWithError error: NSError!)
{
print("sharer NSError")
print(error.description)
}
func sharerDidCancel(sharer: FBSDKSharing!)
{
print("sharerDidCancel")
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)