http://m.blog.csdn.net/blog/u012189584/43236379
Social.framework支持的分享平台(打开手机上的“设置”即可看到)(如Twitter、facebook 、fickr、vimeo、新浪微博、腾讯微博)等。使用Social.framework之前得在"设置"中添加相应分享平台的账号.
[SLComposeViewControllerisAvailableForServiceType:SLServiceTypeSinaWeibo]
SLComposeViewController *cc= [SLComposeViewControllercomposeViewControllerForServiceType:SLServiceTypeSinaWeibo];
[selfpresentViewController:ccanimated:YEScompletion:nil];
[cc setInitialText:@"测试文字"];// 初始化文字
[ccaddImage:[UIImageimageNamed:@"lufy"]];// 配图
// 新浪微博服务不可用
if (![SLComposeViewController isAvailableForServiceType:SLServiceTypeSinaWeibo]) return;
// 1.创建分享控制器
SLComposeViewController *slv = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeSinaWeibo];
// 设置初始化数据
[slv setInitialText:@"郭XX xx xx -- 新闻链接:http://www.baidu.com/news/5435345"];
[slv addImage:[UIImage imageNamed:@"lufy"]];
// 2.显示控制器
[self presentViewController:slv animated:YES completion:nil];
// 3.设置block监听
slv.completionHandler = ^(SLComposeViewControllerResult result){
if (result == SLComposeViewControllerResultCancelled) {
NSLog(@"取消发送");
} else {
NSLog(@"发送完毕");
}
};