iOS6 facebook整合(图像文章)
问题描述:
我只想在我的应用程序中添加Facebook功能。我想通过我的应用程序在Facebook上添加图像。
I just want to add facebook functionality in my app. i want to add image on facebook through my app.
是否有适用于iOS6的示例。
Is there any sample available for iOS6.
答
官方文档, SLComposeViewController类参考 。
Visit this official documentation, SLComposeViewController Class Reference.
苹果已经创建了一个社交框架。 SLComposeViewController
是将处理所有社交互动请求的控制器。
Apple has created a social framework. SLComposeViewController
is the controller which will handle all the request for social interaction.
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
SLComposeViewController *objSLComposeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
SLComposeViewControllerCompletionHandler __block completionHandler=^(SLComposeViewControllerResult result)
{
[objSLComposeViewController dismissViewControllerAnimated:YES completion:nil];
switch(result)
{
case SLComposeViewControllerResultCancelled:
default:
break;
case SLComposeViewControllerResultDone:
break;
}
}
[objSLComposeViewController addImage:yourImage];
[objSLComposeViewController setInitialText:@"YourInitialText"];
[objSLComposeViewController addURL:[NSURL URLWithString:@"YourURL"]];
[objSLComposeViewController setCompletionHandler:completionHandler];
[self presentModalviewController:objSLComposeViewController animated:YES completion:nil];
}
我希望这有助于。