SLComposeViewController setInitialText未显示在视图

时间:2015-04-30 14:42:10

标签: ios facebook slcomposeviewcontroller

我正在尝试使用SLComposeViewController在我的iOS App中共享链接。

SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controller setInitialText:@"Here's the link I promised:"];
[controller addURL:[NSURL URLWithString:@"http://www.url.com"]];
[self presentViewController:controller animated:YES completion:nil];

当控制器出现时,输入框中没有文字。您可以添加文本并将其发送正常(URL也会在Post中正确显示)。

我刚安装了FacebookSDK 4.01,它是iOS 7/8应用程序。

关于为什么初始文本没有出现的任何想法。我甚至试图在没有URL的情况下这样做,只是做文本,但没有。

附加说明:如果我删除了addURL,那么当我点击“发布”时该应用会冻结,并且该帖子永远不会被发送。

感谢您的帮助!!!

2 个答案:

答案 0 :(得分:8)

I found a nice way to work around this which still gives the user control.

For Facebook only, just before presenting the SLComposerViewController I show a self dismissing alert (with a 6 second dismissal if OK wasn't tapped). This alert will contain "Write to your friends about how you did playing !\n\nYou can just PASTE for a preset message.".

Right after showing the alert, I then use the following to post a preset message to the UIPasteboard:

    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
    pasteboard.string = msg;

So then the SLComposeViewController is presented and an alert view right over it. Once the user dismisses the alert view (or 6 seconds passes and it self dismisses), that the user has the option to just PASTE, right in the message text, your preset message. Or not, that's the beauty of it.

Hope this helps some others get around what FB decided to suddenly enforce. I didn't even realize it was against policy to use the setInitialText method for FB.

Cheers.

答案 1 :(得分:7)

此行为是有意的。另请参阅此错误报告:https://developers.facebook.com/bugs/962985360399542/。正如@WizKid所提到的那样,预先填写文本是违反政策的。直到最近,你仍然可以这样做(违反政策)但现在实际上已经实施了。

你无能为力;这是Facebook的政策执行。

此外,相关的Rdar:http://openradar.appspot.com/20709403