适用于iOS的Facebook SDK:未显示FBSDKShareDialog [英] Facebook SDK for iOS: FBSDKShareDialog is not shown
本文介绍了适用于iOS的Facebook SDK:未显示FBSDKShareDialog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是iOS的新手,我想使用iOS的Facebook SDK共享链接.我的代码如下:
I am a newbie in iOS, and I would like to share a link using the Facebook SDK for iOS. My code's as follows:
@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!)
正在执行,这意味着出现了问题,但是我可以没关系.
I have also implemented the FBSDKSharingDelegate
methods, but I am not able to receive the share dialog when I press this button, and the method func sharer(sharer: FBSDKSharing!, didFailWithError error: NSError!)
is being executed, which means something is going wrong, but I can't figure it out.
谢谢.
推荐答案
更改此行
content.contentURL = NSURL(string: "www.google.com")
进入
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")
}
这篇关于适用于iOS的Facebook SDK:未显示FBSDKShareDialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文