从4月24日起,在最新的Facebook iPhone应用更新中,SLComposeViewController的功能不再像预期的那样工作。指定的任何初始文本都将被忽略,尽管setInitialText方法会返回true,就好像它成功了一样。无论你点击"Done“还是"Cancel”,对话框都会返回"Done“。我意识到这是一个苹果电话,我甚至没有使用Facebook SDK,但我已经验证了一切都可以与安装的Facebook应用程序的以前版本完美地工作,但当你在iPhone上升级Facebook应用程序时,这个功能不再像预期的那样工作。请注意,完成处理程序的结果现在总是返回"Done“-即使您点击了"Cancel”,而且setInitialText:现在什么也不做。已在4月24日发布之前验证相同的代码是否正常工作。
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controller setInitialText:@"hiiiiiii"];
[controller setCompletionHandler:^(SLComposeViewControllerResult result)
{
if (result == SLComposeViewControllerResultCancelled)
{
NSLog(@"The user cancelled.");
}
else if (result == SLComposeViewControllerResultDone)
{
NSLog(@"The user posted to Facebook");
}
}];
[self presentViewController:controller animated:YES completion:nil];
}
else
{
SCLAlertView *alert = [[SCLAlertView alloc] init];
[alert showWarning:self title:@"alert" subTitle:@"facebook not installed" closeButtonTitle:@"ok" duration:0.0f];
}发布于 2016-02-09 13:57:14
在写这篇文章时,FB仍然不允许设置初始文本,即使使用FB SDK也是如此。
我实现的一种绕过这个问题的方法是将内容复制到剪贴板,并显示一个对话框,通知用户他们可以粘贴预设内容。
发布于 2015-07-17 22:32:14
setInitialText:不再工作了,因为Facebook最近改变了关于预填充的政策,但addURL: 仍在工作,可能会成为有用的。
SLComposeViewController *mySLComposerSheet = [[SLComposeViewController alloc] init];
mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
NSURL *url = [[NSURL alloc] initWithString:linkString];
[mySLComposerSheet addURL:url];
[self presentViewController:mySLComposerSheet animated:YES completion:nil];
[mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
NSString *output;
switch (result) {
case SLComposeViewControllerResultCancelled:
NSLog(@"SLComposeViewControllerResultCancelled");
break;
case SLComposeViewControllerResultDone:
NSLog(@"SLComposeViewControllerResultDone");
break;
}
}];这样我就可以用我的应用程序的URL预先填充Facebook post composer。
我希望它是有用的。
https://stackoverflow.com/questions/30570457
复制相似问题