我正在尝试使用 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/