您要做的是等到用户完成 twitter 帖子后,再显示 facebook 对话框。您可以对其进行编码,以便在 twitter 对话框的完成处理程序中显示 facebook 对话框:
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) //check if Twitter Account is linked
{
mySLComposerSheet = [[SLComposeViewController alloc] init]; //initiate the Social Controller
mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; //Tell him with what social plattform to use it, e.g. facebook or twitter
[mySLComposerSheet setInitialText:[NSString stringWithFormat:@"Test",mySLComposerSheet.serviceType]]; //the message you want to post
[mySLComposerSheet addImage:yourimage]; //an image you could post
[self presentViewController:mySLComposerSheet animated:YES completion:nil];
}
[mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
// dismiss the Tweet Sheet
dispatch_async(dispatch_get_main_queue(), ^{
[self dismissViewControllerAnimated:NO completion:^{
[self shareFacebook];
}];
});
}];
编辑:您需要先关闭控制器,然后在关闭控制器后调用 facebook 方法。您需要在主线程上关闭控制器,因为不能保证在主线程上调用完成处理程序。
然而,从用户体验的角度来看,用户被迫同时分享到 twitter 和 Facebook 是相当麻烦的。也许有更好的方法来进行这种共享?