共享时,UIActivityViewController不显示facebook上的链接

时间:2015-12-02 07:34:10

标签: ios facebook uiactivityviewcontroller

当我在facebook上使用共享功能时,我无法看到字符串和链接,下面是示例代码。

NSArray * activityItems = @[[NSString stringWithFormat:@"Some initial text."], [NSURL URLWithString:@"http://www.google.com"]];
NSArray * applicationActivities = nil;
NSArray * excludeActivities = @[UIActivityTypeAssignToContact, UIActivityTypeCopyToPasteboard, UIActivityTypePostToWeibo, UIActivityTypePrint, UIActivityTypeMessage];

UIActivityViewController * activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:applicationActivities];
activityController.excludedActivityTypes = excludeActivities;

[self presentViewController:activityController animated:YES completion:nil];

2 个答案:

答案 0 :(得分:1)

您的链接必须是NSURL对象:

NSString *link = @"http://itunes.apple.com/app/id00000000";
NSArray *activityItems = @[ [NSURL URLWithString: link] ];

答案 1 :(得分:0)

您的链接在那里,但它不会作为帖子文本的一部分内联显示。相反,它被视为类似附件的预览:

enter image description here

如果您想在文字中看到自己的链接,请将其添加到您的NSString活动项目中:

NSArray * activityItems = @[[NSString stringWithFormat:@"Some initial text. An inline link http://www.yahoo.com"]];

这样你就会看到字符串和链接:

enter image description here