截至4月24日,最新的Facebook iPhone应用程序更新,SLComposeViewController的功能不再像预期的那样有效.指定的任何初始文本都会被忽略,尽管setInitialText方法返回true,就好像它成功了一样.然后,无论您点击"完成"还是"取消",对话框都会返回"完成".我知道这是一个Apple电话,我甚至没有使用Facebook SDK,但我已经确认一切都与之前安装的Facebook App版本完美配合,但当你在iPhone上升级Facebook应用程序时,此功能不再按预期工作.请注意,完成处理程序的结果现在总是返回"完成" - 即使您点击"取消"也是,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];
}
Run Code Online (Sandbox Code Playgroud)