我使用 SLComposeViewController 来共享图像和 url,如下所示:
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 共享视频文件吗?提前致谢。