1.添加所需的第三方框架,在mod.com上下载sdk
2.添加完sdk后,在Xcode里导入所需的框架
3.在appdelegate里添加
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[ShareSDK registerApp:@"7238909cf352"];//mod.com开发者上添加应用返回的appkey
//使用的是新浪微博分享的时候按照下面的方法
[ShareSDK connectSinaWeiboWithAppKey:@"3533917090" //新浪微博的appkey
appSecret:@"eea4e51b372918ef6b3b793927a1cc21" //新浪微博的密码
redirectUri:@"http://mooc.huiwen.com"]; //注册时的网址
4.在点击分享时的方法
id<ISSContent> publishContent = [ShareSDK content:_title.text //分享的文字
defaultContent:@"测试一下"
image:[ShareSDK imageWithUrl:self.model.image[@"raw"]] //分享的图片
title:@"ShareSDK"
url:@"http://www.mob.com"
description:@"这是一条测试信息"
mediaType:SSPublishContentMediaTypeNews];
//创建弹出菜单容器
id<ISSContainer> container = [ShareSDK container];
[container setIPadContainerWithView:sender arrowDirect:UIPopoverArrowDirectionUp];
//弹出分享菜单
[ShareSDK showShareActionSheet:container
shareList:nil
content:publishContent
statusBarTips:YES
authOptions:nil
shareOptions:nil
result:^(ShareType type, SSResponseState state, id<ISSPlatformShareInfo> statusInfo, id<ICMErrorInfo> error, BOOL end) {
if (state == SSResponseStateSuccess)
{
NSLog(NSLocalizedString(@"TEXT_ShARE_SUC", @"分享成功"));
}
else if (state == SSResponseStateFail)
{
NSLog(NSLocalizedString(@"TEXT_ShARE_FAI", @"分享失败,错误码:%d,错误描述:%@"), [error errorCode], [error errorDescription]);
}
}];