正文
typedef NS_ENUM(NSUInteger,umSocialShareType) {
UMS_SHARE_TYPE_IMAGE = 0,//只分享图片
UMS_SHARE_TYPE_ALL = 1,//图片文字链接
};
方法1.点击需要分享的地方弹出多个分享平台,然后选择具体的平台进行分享。
根据不同的枚举值确定点击的某个平台的分享类型,然后传入不同的数据参数。
/**
* 弹出多个平台 选择分享至某一个
* sharePlatType 分享的类型 图片模式 还是图文链接模式
* shareTitle 分享的标题 图片模式时可传nil
* shareCotent 分享的内容 图片模式时可传nil
* shareImage 分享的图片 UIImage类对象,也可以是NSdata类对象,也可以是图片链接imageUrl NSString类对象
* shareWebUrl 分享点击对应的web页的URL 图片模式时可传nil
* @param block 回调block
*/
- (void)umSocial_ShareWithControll:(UIViewController *)PrsentControll withPlatShareType:(umSocialShareType)shareType withTitle:(NSString*)shareTitle withCotent:(NSString*)shareCotent withImage:(id)shareImage withWebUrl:(NSString*)shareWebUrl withCompletionHandler:(UMSocialRequestCompletionHandler)completionHandler;
方法的实现如下:
/**
* 弹出多个平台 选择分享至某一个
* sharePlatType 分享的类型 图片模式 还是图文链接模式
* @param block 回调block
*/
- (void)umSocial_ShareWithControll:(UIViewController *)PrsentControll withPlatShareType:(umSocialShareType)shareType withTitle:(NSString*)shareTitle withCotent:(NSString*)shareCotent withImage:(id)shareImage withWebUrl:(NSString*)shareWebUrl withCompletionHandler:(UMSocialRequestCompletionHandler)completionHandler{
switch (shareType) {
case UMS_SHARE_TYPE_IMAGE://只分享图片
{
[UMSocialUIManager setPreDefinePlatforms:platFormArray];
[UMSocialUIManager showShareMenuViewInWindowWithPlatformSelectionBlock:^(UMSocialPlatformType platformType, NSDictionary *userInfo) {
[self runShareImageWithType:platformType WithControll:PrsentControll withImage:shareImage withCompletionHandler:(UMSocialRequestCompletionHandler)completionHandler ];
}];
}
break;
case UMS_SHARE_TYPE_ALL://图片文字链接
{
[UMSocialUIManager setPreDefinePlatforms:platFormArray];
[UMSocialUIManager showShareMenuViewInWindowWithPlatformSelectionBlock:^(UMSocialPlatformType platformType, NSDictionary *userInfo) {
[self runShareAllWithType:platformType WithControll:PrsentControll withTitle:shareTitle withCotent:shareCotent withImage:shareImage withWebUrl:shareWebUrl withCompletionHandler:(UMSocialRequestCompletionHandler)completionHandler ];
}];
}
break