ios - FBSDKShareLinkContent 没有设置 contentDescription 和 contentTitle

标签 ios iphone facebook sdk share

我正在尝试使用 FBSDKShareLinkContent 在 Facebook 上共享一个链接。

我已经设置了 URL、描述和标题。 SDK 会根据从 contentURL 中抓取的信息自动填充标题和描述。

但我想设置我在代码中给出的自定义标题和描述。无论如何要避免这种行为?

  FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
[content setContentTitle:@"Testing title"];
[content setContentDescription:@"Testing description."];
content.contentURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://www.google.co.in/"]];
[FBSDKShareDialog showFromViewController:self
withContent:content
delegate:nil];

最佳答案

我遇到了同样的问题并找到了一种解决方法——将 FBSDKShareDialog 实例的模式直接设置为 FBSDKShareDialogModeFeedWeb。

FBSDKShareDialog* dialog = [[FBSDKShareDialog alloc] init];
dialog.mode = FBSDKShareDialogModeFeedWeb;
dialog.shareContent = content;
dialog.fromViewController = self;
[dialog show];

它在应用内的 UIWebView 中显示提要对话框,其中包含带有正确标题和描述的帖子预览。

关于ios - FBSDKShareLinkContent 没有设置 contentDescription 和 contentTitle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29916591/

相关文章:

ios - Alamofire 不工作(Swift/Xcode 8)

ios - 设置文本时停止 UITextField 调整大小

ios - 拍摄应用快照后,当我的 iOS 应用进入后台时,如何节省 subview 中使用的内存

iphone - 从用户那里获取调试信息

ios - 如何在 Swift 中通过 Facebook SDK 获取两个用户之间的共同好友

ios - 尽管 userInteractionEnabled = true,但 UIView 中的 UIButton 不响应触摸事件

iphone - 如何将drawRect与UIScrollView的子类一起使用?

ios - 我的应用程序上的 Facebook 分享按钮 - 我必须使用 Facebook SDK 吗?

php - 使用 PHP 使用 CSS 样式选择器从大字符串中提取元素?

iphone - 基于 View 和基于窗口的应用程序模板之间的主要区别?