相信大家很多项目只能够用的都是友盟分享,那么我们就对友盟的调用进行机一部的封装,这样项目简单,方便改
PPX_ShareManage.h
/*
*viewController 你的控制器
*shareTitle 标题
*shareContent 内容
*shareImage:(id)shareImage 必须是UIImage或者NSData
*shareUrl 分享出去的 url
*
*/
+ (void)showViewController:(UIViewController *)viewController
shareTitle:(NSString *)shareTitle
shareContent:(NSString *)shareContent
shareImage:(id)shareImage
shareUrl:(NSString *)shareUrl;
//有时候一些变态的需求微信里求分享出不一样的网址或者图片什么的
+ (void)configSinaIamge:(UIImage *)image;
+ (void)configWeChatUrl:(NSString *)url;
PPX_ShareManage.m
+ (void)showViewController:(UIViewController *)viewController
shareTitle:(NSString *)shareTitle
shareContent:(NSString *)shareContent
shareImage:(id)shareImage
shareUrl:(NSString *)shareUrl
{
[UMSocialConfig hiddenNotInstallPlatforms:nil];
[UMSocialData defaultData].extConfig.qqData.qqMessageType = UMSocialQQMessageTypeDefault;
[UMSocialData defaultData].extConfig.qqData.url = shareUrl;
[UMSocialData defaultData].extConfig.wechatSessionData.wxMessageType = UMSocialWXMessageTypeWeb;
[UMSocialData defaultData].extConfig.wechatSessionData.url = shareUrl;
[UMSocialData defaultData].extConfig.wechatTimelineData.wxMessageType = UMSocialWXMessageTypeWeb;
[UMSocialData defaultData].extConfig.wechatTimelineData.url = shareUrl;
[UMSocialData defaultData].extConfig.sinaData.shareText = [NSString stringWithFormat:@"%@%@",shareTitle,shareUrl];
[UMSocialData defaultData].extConfig.title = shareTitle;
[UMSocialSnsService presentSnsIconSheetView:viewController
appKey:XTY_UMKey
shareText:shareContent
shareImage:shareImage
shareToSnsNames:@[UMShareToWechatSession,UMShareToWechatTimeline,UMShareToQQ,UMShareToSina]
delegate:nil];
}
+ (void)configSinaIamge:(UIImage *)image
{
[UMSocialData defaultData].extConfig.sinaData.shareImage = image;
}
+ (void)configWeChatUrl:(NSString *)url
{
[UMSocialData defaultData].extConfig.wechatSessionData.url = url;
}
都是干货拒绝稀得鲁的啊..如果没看明白给我留言.下次会说更更好..你们的支持是前进的动力
网友评论