标签:
一、如何实现社交分享
(百度还有个“社会化登录组件”:http://developer.baidu.com/soc/login)
二、Social.framework使用步骤
[SLComposeViewController isAvailableForServiceType:SLServiceTypeSinaWeibo]
SLComposeViewController *cc = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeSinaWeibo];
[self presentViewController:cc animated:YES completion:nil];
[cc setInitialText:@"测试文字"]; // 初始化文字
[cc addImage:[UIImage imageNamed:@"lufy"]]; // 配图
三、社交平台简介
1.Twitter——推特
代码:
1 // 2 // ViewController.m 3 // IOS_0404_系统自带分享 4 // 5 // Created by ma c on 16/4/4. 6 // Copyright © 2016年 博文科技. All rights reserved. 7 // 8 9 #import "ViewController.h" 10 #import <Social/Social.h> 11 12 @interface ViewController () 13 14 @end 15 16 @implementation ViewController 17 18 - (void)viewDidLoad { 19 [super viewDidLoad]; 20 self.view.backgroundColor = [UIColor cyanColor]; 21 } 22 23 - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event 24 { 25 //1.判断服务是否可用 26 if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeSinaWeibo]) { 27 NSLog(@"分享可用"); 28 } 29 //2.创建分享控制器 30 SLComposeViewController *composeVC = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeSinaWeibo]; 31 //设置默认数据 32 [composeVC setInitialText:@"呵呵哈哈"]; 33 [composeVC addImage:[UIImage imageNamed:@""]]; 34 //3.弹出分享控制器 35 [self presentViewController:composeVC animated:nil completion:nil]; 36 //4.监听分享状态 37 composeVC.completionHandler = ^(SLComposeViewControllerResult result){ 38 39 if (result == SLComposeViewControllerResultCancelled) { 40 NSLog(@"取消发送"); 41 } else { 42 NSLog(@"发送成功"); 43 } 44 45 }; 46 47 } 48 49 @end
标签:
原文地址:http://www.cnblogs.com/oc-bowen/p/5351854.html