@SanMao
2015-08-06T00:33:00.000000Z
字数 769
阅读 1274
社交分享
// 判断分享平台是否可用
if (![SLComposeViewController isAvailableForServiceType:SLServiceTypeSinaWeibo]) {
NSLog(@"请到设置界面添加sina账号");
return;
}
// 创建分享控制器
SLComposeViewController *composeVc = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeSinaWeibo];
// 设置分享的内容
[composeVc setInitialText:@"梦想还是要有的,万一实现了呢"];
[composeVc addImage:[UIImage imageNamed:@"xingxing"]];
// 弹出分享控制器
[self presentViewController:composeVc animated:YES completion:nil];
// 监听分享结果
composeVc.completionHandler = ^(SLComposeViewControllerResult result){
if (result == SLComposeViewControllerResultCancelled) {
NSLog(@"用户取消了分享");
}else{
NSLog(@"用户已经分享了");
}
};