标签:
1 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 2 { 3 // 1.判断平台是否可用 4 if (![SLComposeViewController isAvailableForServiceType:SLServiceTypeSinaWeibo]) { 5 NSLog(@"平台不可用,或者没有配置相关的帐号"); 6 return; 7 } 8 9 // 2.创建分享的控制器 10 SLComposeViewController *composeVc = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeSinaWeibo]; 11 12 // 2.1.添加分享的文字 13 [composeVc setInitialText:@"我是一个codeMan"]; 14 15 // 2.2.添加一个图片 16 [composeVc addImage:[UIImage imageNamed:@"xingxing"]]; 17 18 // 2.3.添加一个分享的链接 19 [composeVc addURL:[NSURL URLWithString:@"www.baidu.com"]]; 20 21 // 3.弹出分享控制器 22 [self presentViewController:composeVc animated:YES completion:nil]; 23 24 // 4.监听用户点击了取消还是发送 25 composeVc.completionHandler = ^(SLComposeViewControllerResult result) { 26 if (result == SLComposeViewControllerResultCancelled) { 27 NSLog(@"点击了取消"); 28 } else { 29 NSLog(@"点击了发送"); 30 } 31 }; 32 }
标签:
原文地址:http://www.cnblogs.com/gchlcc/p/5582047.html