我使用SLComposeViewController来共享图像和网址,如下所示:
SLComposeViewController *fbComposer =
[SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeFacebook];
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
SLComposeViewControllerCompletionHandler __block completionHandler=
^(SLComposeViewControllerResult result){
[fbComposer dismissViewControllerAnimated:YES completion:nil];
switch(result){
case SLComposeViewControllerResultCancelled:
default:
{
NSLog(@"Cancelled.....");
}
break;
case SLComposeViewControllerResultDone:
{
NSLog(@"Posted....");
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Sent"
message:nil
delegate:nil
cancelButtonTitle:@"Dismiss"
otherButtonTitles: nil];
[alert show];
}
break;
}};
NSString *message=@"posting to FB test";
[fbComposer setInitialText:message];
[fbComposer addImage:[UIImage imageNamed:@"2.jpg"]];
[fbComposer addURL:[NSURL URLWithString:@"http://www.youtube.com/watch?v=GoZ2Be2zLq8"]];
[fbComposer setCompletionHandler:completionHandler];
[self presentViewController:fbComposer animated:YES completion:nil];
}
我们还可以使用SLComposeViewController共享视频文件吗? 提前谢谢。
答案 0 :(得分:4)
不,我们无法使用SLComposeViewController共享视频文件。要发送视频文件,我们必须
使用Fb Graph API。请参阅此链接&使用它,您可以轻松地将视频文件发送到fb:
答案 1 :(得分:0)
如果您想要将视频网址分享到Facebook,可以使用以下代码。
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controller setInitialText:string];
[controller addImage:image];
[controller addURL:[NSURL URLWithString:URLString]];
[self.controller presentViewController:controller animated:YES completion:Nil];
[controller setCompletionHandler:^(SLComposeViewControllerResult result){
switch (result) {
case SLComposeViewControllerResultCancelled:
// Cancelled
break;
case SLComposeViewControllerResultDone:
// Success
break;
default:
break;
}
}];