Facebook的SLComposeViewController URL显示在正文中,如果URL和图像都存在

使用SLComposeViewController时,如果图像和URL都存在,当发布到Facebook时,我会注意到好奇的行为。 具体而言,如果您同时拥有图片和url,则在SLComposeViewController的视图中,URL会出现在Facebook文章的SLComposeViewController ,紧跟在initialText如果我执行以下操作:

 SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; NSString *text = @"This is a test Facebook post with SLComposeViewController."; NSURL *url = [NSURL URLWithString:@"http://http://stackoverflow.com/questions/12503287/tutorial-for-slcomposeviewcontroller-sharing"]; UIImage *image = ...; [controller setInitialText:text]; [controller addURL:url]; [controller addImage:image]; [self presentViewController:controller animated:YES completion:nil]; 

这显然是一个麻烦,因为如果URL很长,初始文本被从SLComposeViewController的视图的可见部分SLComposeViewController ,我只能看到URL的后面部分:

在这里输入图像说明

如果我重复这个过程,这次不会将图像添加到post中,URL的文本方便地不会显示在主体中(即使它正常在线显示)。

在这里输入图像说明

底线,只有存在图像并且URL在post主体中显示。 当我使用FBNativeDialogs时,我看到了相同的模式。

有没有什么办法阻止与SLComposeViewController行为,这样我可以有图像和URL连接到Facebook的post,而不暴露用户的网站的长,丑陋的url? 显然,我可以使用任何非SLComposeViewController解决scheme(例如,devise我自己的用户界面来编写Facebook的post,使用Facebook的弃用饲料对话框等)。 只是想知道如果我忽略了一些明显的SLComposeViewController解决scheme。

最后,我放弃了SLComposeViewController (以及FBNativeDialogs )。 他们提出了一个很好的,整合的感觉,但鉴于我的post总是包括照片和url,这是行不通的。 最重要的是,post没有被正确的归因于我的应用程序。

所以,最后,我写了我自己的用户界面,并使用如此处所述的Facebook SDK 3.1 FBRequestConnection 。 我认为我们都必须制作自己的用户界面是有点愚蠢的,因为本地用户界面的弱点,但它是什么。

新的对话似乎是围绕着你提供的大多数共享数据作为提供的链接指向的网站上的标签。 喜欢这个:

标题:

 <title>TITLE</title> 

描述:

 <meta name="description" content="DESCRIPTION"> 

图片:

 <meta property="og:image" content="IMAGE_URL"> 

应用程序ID:

 <meta property="fb:app_id" content="APP_ID"> 

这样你只需要提供初始文本和一个URL。 你可以看看官方的Youtube应用程序是如何分享Facebook的例子。

 TWTweetComposeViewController *twitter = [[TWTweetComposeViewController alloc] init]; NSString *format = @"“%@” %@ /via @DesignSceneApp"; NSString *message = [NSString stringWithFormat:format, title, url] NSUInteger idx = title.length; while (![twitter setInitialText:message]) { idx -= 5; if (idx > 5) { message = [NSString stringWithFormat:format, [NSString stringWithFormat:@"%@…", [title substringToIndex:idx]], url ]; } else { // Give up on the title. message = [NSString stringWithFormat:@"%@ /via @DesignSceneApp", url]; [twitter setInitialText:message]; break; } } [self presentViewController:twitter animated:YES completion:nil];