在新的 xcode4.5 中,我们找到了要在社交网络中共享的新类 SLComposeViewController,我正在阅读类参考,但我仍然不明白如何实现。
因此,如果您有任何想法,那将非常有帮助。谢谢
对不起,我只是找到方法。这里是:
您需要将 Social.framework 添加到您的项目中。将以下 #import "Social/Social.h" 添加到您的文件中
您可以创建 3 种类型的服务:
SLServiceTypeTwitter
SLServiceTypeFacebook
SLServiceTypeSinaWeibo
Facebook 的示例。
SLComposeViewController *fbController =
[SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeFacebook];
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
SLComposeViewControllerCompletionHandler __block completionHandler=
^(SLComposeViewControllerResult result){
[fbController 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;
}};
[fbController addImage:[UIImage imageNamed:@"your_image.jpg"]];
[fbController setInitialText:@"The initial text you want to send"];
[fbController addURL:[NSURL URLWithString:@"the url you wanna share"]];
[fbController setCompletionHandler:completionHandler];
[self presentViewController:fbController animated:YES completion:nil];
}
希望这个对你有帮助。如果您想要其他社交网络,请将 SLServiceTypeFacebook 更改为其他两个中的任何一个。
I have also face this kinds of problem in my last project and I have found Sample code for SLComposeViewController for the same. I think it will helps you.
Thanks
您可以在 github 上找到一个用于实现 iOS 6 社交共享的插入式表格视图单元。免责声明 - 我是作者。