UIImage* shareImage = [UIImageimageNamed:@"name.png"];
NSString *titleLblStr =@"项目名称";
//1、创建分享参数
// (注意:图片必须要在Xcode左边目录里面,名称必须要传正确,如果要分享网络图片,可以这样传iamge参数 images:@[@"http://mob.com/Assets/images/logo.png?v=20150320"])
if (shareImage) {
NSString *shareUrl=[NSStringstringWithFormat:@"%@",@“http://www.baidu.com”];
NSLog(@"shareUrl:%@",shareUrl);
NSMutableDictionary *shareParams = [NSMutableDictionarydictionary];
[shareParams SSDKSetupShareParamsByText:[NSStringstringWithFormat:@"%@",@"分享的内容"]
images:shareImage
url:[NSURLURLWithString:shareUrl]
title:titleLblStr
type:SSDKContentTypeAuto];
//2、分享(可以弹出我们的分享菜单和编辑界面)
[ShareSDKshowShareActionSheet:nil//要显示菜单的视图, iPad版中此参数作为弹出菜单的参照视图,只有传这个才可以弹出我们的分享菜单,可以传分享的按钮对象或者自己创建小的view对象,iPhone可以传nil不会影响
items:@[@(SSDKPlatformSubTypeWechatSession),
@(SSDKPlatformSubTypeWechatTimeline),
@(SSDKPlatformTypeSinaWeibo),
@(SSDKPlatformSubTypeQQFriend),
@(SSDKPlatformTypeTencentWeibo),
@(SSDKPlatformTypeMail),
@(SSDKPlatformTypeSMS)
]
shareParams:shareParams
onShareStateChanged:^(SSDKResponseState state,SSDKPlatformType platformType,NSDictionary *userData, SSDKContentEntity *contentEntity,NSError *error, BOOL end) {
switch (state) {
caseSSDKResponseStateSuccess:
{
UIAlertView *alertView = [[UIAlertViewalloc] initWithTitle:@"分享成功"
message:nil
delegate:nil
cancelButtonTitle:@"确定"
otherButtonTitles:nil];
[alertView show];
break;
}
caseSSDKResponseStateFail:
{
UIAlertView *alert = [[UIAlertViewalloc] initWithTitle:@"分享失败"
message:[NSStringstringWithFormat:@"%@",error]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil,nil];
[alert show];
break;
}
default:
break;
}
}
];
}