ShareSDK自定义分享弹出视图

ShareSDK自带视图弹出框感觉没有那么美观,但是ShareSDK也预留了自定义视图调用分享的方法,可以根据自己的需求定义比较美观的视图,然后调用相对应的方法就可以了,一起来看看,挺简单的。

主要代码:

-(void)clickedSharedItem:(UIButton*)button {

intshareType =0;

switch(button.tag) {

case10: {

shareType =SSDKPlatformSubTypeWechatSession;

}

break;

case11: {

shareType =SSDKPlatformSubTypeWechatTimeline;

}

break;

case12: {

shareType =SSDKPlatformSubTypeQQFriend;

}

break;

default:

break;

}

NSMutableDictionary*shareParams = [NSMutableDictionarydictionary];

[shareParamsSSDKSetupShareParamsByText:@"注册就送"

images:self.single.headerimg

url:[NSURLURLWithString:shareUrl]

title:@"你敢来,我就敢送!"

type:SSDKContentTypeAuto];

[ShareSDK share:shareTypeparameters:shareParams onStateChanged:^(SSDKResponseStatestate,NSDictionary*userData,SSDKContentEntity*contentEntity,NSError*error) {

switch(state) {

caseSSDKResponseStateSuccess:{

if(self.block) {

self.block(state,@"succeed");

}

break;

}

caseSSDKResponseStateFail: {

if(self.block) {

NSString*resultString =@"分享失败!";

if(shareType ==SSDKPlatformSubTypeQQFriend&& ![QQApiInterfaceisQQInstalled]) {

resultString =@"您的手机没有安装QQ!";

}elseif((shareType ==SSDKPlatformSubTypeWechatSession|| shareType ==SSDKPlatformSubTypeWechatTimeline) && ![WXApiisWXAppInstalled]) {

resultString =@"您的手机没有安装微信!";

}

self.block(state,resultString);

}

break;

}

default:

break;

}

}];

}

ShareSDK自定义分享弹出视图_第1张图片

你可能感兴趣的:(ShareSDK自定义分享弹出视图)