zoukankan      html  css  js  c++  java
  • 友盟分享实现

    实现弹出分享框控制器代码

    #import <UShareUI/UShareUI.h>

     

    - (void)viewDidLoad {

        [super viewDidLoad];

     

        [UMSocialUIManager setPreDefinePlatforms:@[@(UMSocialPlatformType_Sina),@(UMSocialPlatformType_QQ),@(UMSocialPlatformType_WechatSession)]];

        [UMSocialUIManager showShareMenuViewInWindowWithPlatformSelectionBlock:^(UMSocialPlatformType platformType, NSDictionary *userInfo) {

            // 根据获取的platformType确定所选平台进行下一步操作

        }];

        //设置用户自定义的平台

        [UMSocialUIManager addCustomPlatformWithoutFilted:UMSocialPlatformType_UserDefine_Begin+2

                                         withPlatformIcon:[UIImage imageNamed:@"zhongjianggonggao_xyzj"]

                                         withPlatformName:@"复制链接"];

        

        [UMSocialUIManager setPreDefinePlatforms:@[@(UMSocialPlatformType_UserDefine_Begin+2),

                                                   @(UMSocialPlatformType_WechatSession),

                                                   @(UMSocialPlatformType_WechatTimeLine),

                                                   @(UMSocialPlatformType_QQ),

                                                   @(UMSocialPlatformType_Qzone),

                                                   @(UMSocialPlatformType_Sina),

                                                   ]];

     

        UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];

        [button setTitle:@"页面底部菜单-1" forState:UIControlStateNormal];

        button.backgroundColor=[UIColor orangeColor];

        [button addTarget:self action:@selector(showBottomNormalView) forControlEvents:UIControlEventTouchUpInside];

        [self.view addSubview:button];

     

    }

    - (void)showBottomNormalView

    {

    //    [UMSocialUIManager addCustomPlatformWithoutFilted:UMSocialPlatformType_UserDefine_Begin+2

    //                                     withPlatformIcon:[UIImage imageNamed:@"zhongjianggonggao_xyzj"]

    //                                     withPlatformName:@"复制链接"];

        

        [UMSocialShareUIConfig shareInstance].sharePageGroupViewConfig.sharePageGroupViewPostionType = UMSocialSharePageGroupViewPositionType_Bottom;

        [UMSocialShareUIConfig shareInstance].sharePageScrollViewConfig.shareScrollViewPageItemStyleType = UMSocialPlatformItemViewBackgroudType_None;

        [UMSocialUIManager showShareMenuViewInWindowWithPlatformSelectionBlock:^(UMSocialPlatformType platformType, NSDictionary *userInfo) {

            //在回调里面获得点击的

            if (platformType == UMSocialPlatformType_UserDefine_Begin+2)

            {

                NSLog(@"你点击了复制链接按钮");

            }

            else

            {

                [self runShareWithType:platformType];

            }

        }];

    }

    - (void)runShareWithType:(UMSocialPlatformType)type

    {

        //    UMShareTypeViewController *VC = [[UMShareTypeViewController alloc] initWithType:type];

        //    [self.navigationController pushViewController:VC animated:YES];

        

        //创建分享消息对象

        UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];

        //设置文本

        messageObject.text = @"哈撒给";

        

        //调用分享接口

        [[UMSocialManager defaultManager] shareToPlatform:type messageObject:messageObject currentViewController:self completion:^(id data, NSError *error) {

            if (error) {

                UMSocialLogInfo(@"************Share fail with error %@*********",error);

            }else{

                if ([data isKindOfClass:[UMSocialShareResponse class]]) {

                    UMSocialShareResponse *resp = data;

                    //分享结果消息

                    UMSocialLogInfo(@"response message is %@",resp.message);

                    //第三方原始返回的数据

                    UMSocialLogInfo(@"response originalResponse data is %@",resp.originalResponse);

                    

                }

                else

                {

                    UMSocialLogInfo(@"response data is %@",data);

                }

            }

            [self alertWithError:error];

        }];

        

    }

    - (void)alertWithError:(NSError *)error

    {

        NSString *result = nil;

        if (!error) {

            result = [NSString stringWithFormat:@"Share succeed"];

        }

        else{

            NSMutableString *str = [NSMutableString string];

            if (error.userInfo) {

                for (NSString *key in error.userInfo) {

                    [str appendFormat:@"%@ = %@ ", key, error.userInfo[key]];

                }

            }

            if (error) {

                result = [NSString stringWithFormat:@"Share fail with error code: %d %@",(int)error.code, str];

            }

            else{

                result = [NSString stringWithFormat:@"Share fail"];

            }

        }

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"share"

                                                        message:result

                                                       delegate:nil

                                              cancelButtonTitle:NSLocalizedString(@"sure", @"确定")

                                              otherButtonTitles:nil];

        [alert show];

    }

  • 相关阅读:
    Andriod开发环境配置
    Java调用WebService
    Message Modem Develop
    Call .so in Linux
    How to unpack a tar file in windows
    Visual Studio 2010工程目录下的ipch文件夹和.sdf文件
    TWAIN学习记录
    几种调用扫描仪的方案
    Gzip Practice
    Twain Practice
  • 原文地址:https://www.cnblogs.com/niumingming920322/p/6195910.html
Copyright © 2011-2022 走看看