• iOS-调用网页聊天、拨打电话


    @property (nonatomic,strong) UIButton *but;
    @property (nonatomic,strong) UIButton *but1;
    @property (strong, nonatomic) UIView *subView;

    //客服QQ
    -(void)qqAction
    {
        self.but = [UIButton buttonWithType:UIButtonTypeCustom];
        self.but.frame = self.view.bounds;
        self.but.backgroundColor = [UIColor colorWithWhite:0.019 alpha:0.400];
        [self.but addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:self.but];
        
        self.but1 = [UIButton buttonWithType:UIButtonTypeCustom];
        self.but1.frame = self.view.bounds;
        self.but1.backgroundColor = [UIColor colorWithWhite:0.019 alpha:0.400];
        [self.view addSubview:self.but1];
        
        [self.tabBarController.tabBar addSubview:self.but1];
        
        _subView = [[UIView alloc] initWithFrame:CGRectMake(20, screenHeight * 2, screenWidth - 40,200)];
        _subView.alpha = 0;
        _subView.layer.masksToBounds = YES;
        _subView.layer.cornerRadius = 3.0f;
        _subView.backgroundColor = [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0];
        [self.but addSubview:_subView];
        [UIView animateWithDuration:0.001 animations:^{
            CGRect frame = self.subView.frame;
            frame.origin.y = screenHeight / 2-110;
            self.subView.frame = frame;
            self.subView.alpha = 1;
            
            UIButton *closeBtn = [[UIButton alloc] init];
            closeBtn.frame = CGRectMake(_subView.bounds.size.width - 30, 0, 30, 30);
            [closeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            [closeBtn setImage:[UIImage imageNamed:@"btn_关闭_灰色__none"] forState:UIControlStateNormal];
            [closeBtn addTarget:self action:@selector(closeView) forControlEvents:UIControlEventTouchUpInside];
            [_subView addSubview:closeBtn];
            
            UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(14, 45, _subView.bounds.size.width, 30)];
            label1.text = @"钱富宝客服QQ:2797353115";
            label1.textAlignment = NSTextAlignmentLeft;
            label1.textColor = [UIColor colorWithRed:96/256.0 green:103/256.0 blue:127/256.0 alpha:1.0f];
            label1.font = [UIFont systemFontOfSize:16];
            [_subView addSubview:label1];
            
            UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(14, 62, _subView.bounds.size.width - 28, 60)];
            label2.text = @"注:每周一至周五8:00到18:00正常上班,节假日休息。";
            label2.numberOfLines = 2;
            label2.textAlignment = NSTextAlignmentLeft;
            label2.textColor = [UIColor colorWithRed:96/256.0 green:103/256.0 blue:127/256.0 alpha:1.0f];
            label2.font = [UIFont systemFontOfSize:16];
            [_subView addSubview:label2];
            
            UIButton *requestionBtn = [[UIButton alloc] init];
            requestionBtn.frame = CGRectMake(14, 150, _subView.bounds.size.width - 28, 43);
            [requestionBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [requestionBtn setTitle:@"立即咨询" forState:UIControlStateNormal];
            [requestionBtn addTarget:self action:@selector(requestionClick) forControlEvents:UIControlEventTouchUpInside];
            [requestionBtn setBackgroundColor:[UIColor colorWithRed:65/256.0 green:109/256.0 blue:218/256.0 alpha:1.0f]];
            requestionBtn.layer.masksToBounds = YES;
            requestionBtn.layer.cornerRadius = 3.0f;
            
            [_subView addSubview:requestionBtn];
            
        } completion:^(BOOL finished) {
        }];
        
    }

    #pragma mark 在线客服网页跳转的实现部分
    -(void)requestionClick{
        
        UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];
        UILabel *qqLabel = [[UILabel alloc] init];
        qqLabel.text = @"2797353115";
        NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"mqq://im/chat?chat_type=wpa&uin=%@&version=1&src_type=web",qqLabel.text]];
        NSLog(@"----------%@-------",qqLabel.text);
        NSURLRequest *request = [NSURLRequest requestWithURL:url];
        webView.delegate = self;
        [webView loadRequest:request];
        [self.view addSubview:webView];
        
    }
    - (void)webView:(UIWebView *)webView didFailLoadWithError:(nullable NSError *)error
    {
        UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:nil message:@"未安装QQ程序" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles: nil];
        [alertView show];
    }

    #pramra mark 打电话

    //电话
    -(void)hotLineAlertView
    {
        self.but = [UIButton buttonWithType:UIButtonTypeCustom];
        self.but.frame = self.view.bounds;
        self.but.backgroundColor = [UIColor colorWithWhite:0.019 alpha:0.400];
        [self.but addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:self.but];
        
        self.but1 = [UIButton buttonWithType:UIButtonTypeCustom];
        self.but1.frame = self.view.bounds;
        self.but1.backgroundColor = [UIColor colorWithWhite:0.019 alpha:0.400];
        [self.view addSubview:self.but1];
        
        [self.tabBarController.tabBar addSubview:self.but1];
        
        _subView = [[UIView alloc] initWithFrame:CGRectMake(20, screenHeight * 2, screenWidth - 40,200)];
        _subView.alpha = 0;
        _subView.layer.masksToBounds = YES;
        _subView.layer.cornerRadius = 3.0f;
        _subView.backgroundColor = [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0];
        [self.but addSubview:_subView];
        [UIView animateWithDuration:0.001 animations:^{
            CGRect frame = self.subView.frame;
            frame.origin.y = screenHeight / 2-110;
            self.subView.frame = frame;
            self.subView.alpha = 1;
            
            UIButton *closeBtn = [[UIButton alloc] init];
            closeBtn.frame = CGRectMake(_subView.bounds.size.width - 30, 0, 30, 30);
            [closeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            [closeBtn setImage:[UIImage imageNamed:@"btn_关闭_灰色__none"] forState:UIControlStateNormal];
            [closeBtn addTarget:self action:@selector(closeView) forControlEvents:UIControlEventTouchUpInside];
            [_subView addSubview:closeBtn];
            
            UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(14, 45, _subView.bounds.size.width, 30)];
            label1.text = @"钱富宝客服热线:400-607-1818";
            label1.textAlignment = NSTextAlignmentLeft;
            label1.textColor = [UIColor colorWithRed:96/256.0 green:103/256.0 blue:127/256.0 alpha:1.0f];
            label1.font = [UIFont systemFontOfSize:16];
            [_subView addSubview:label1];
            
            UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(14, 62, _subView.bounds.size.width - 28, 60)];
            label2.text = @"注:每周一至周五8:00到18:00正常上班,节假日休息。";
            label2.numberOfLines = 2;
            label2.textAlignment = NSTextAlignmentLeft;
            label2.textColor = [UIColor colorWithRed:96/256.0 green:103/256.0 blue:127/256.0 alpha:1.0f];
            label2.font = [UIFont systemFontOfSize:16];
            [_subView addSubview:label2];
            
            UIButton *hotLineBtn = [[UIButton alloc] init];
            hotLineBtn.frame = CGRectMake(14, 150, _subView.bounds.size.width - 28, 43);
            [hotLineBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [hotLineBtn setTitle:@"拨打热线" forState:UIControlStateNormal];
            [hotLineBtn addTarget:self action:@selector(hotLineClick) forControlEvents:UIControlEventTouchUpInside];
            [hotLineBtn setBackgroundColor:[UIColor colorWithRed:65/256.0 green:109/256.0 blue:218/256.0 alpha:1.0f]];
            hotLineBtn.layer.masksToBounds = YES;
            hotLineBtn.layer.cornerRadius = 3.0f;
            
            [_subView addSubview:hotLineBtn];
            
        } completion:^(BOOL finished) {
        }];
        
    }

    -(void)closeView
    {
        [_but removeFromSuperview];
        [_but1 removeFromSuperview];
    }

    - (void)btnClick:(UIButton *)but
    {
        [_but removeFromSuperview];
        [_but1 removeFromSuperview];
    }
    //播打热线
    -(void)hotLineClick
    {
        [_but removeFromSuperview];
        [_but1 removeFromSuperview];
        
        NSString *number = @"400-607-1818";
        NSString *num = [[NSString alloc]initWithFormat:@"telprompt://%@",number];
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:num]]; //拨号

    }

  • 相关阅读:
    Python(错误的处理方法)
    WP7 QQ词典V1.1 共享源代码
    【原创】Windows Phone真机抓包并分析应用程序的网络通讯(Android、iPhone也适用)
    使用uiautomation自动化重命名pdf书签,使全大写字母变成首字母大写
    分享python分析wave, pcm音频文件
    最近在做的一个wp7地图应用
    HTML5初探 基本的HTML5模版
    HTML5页面架构元素 <header>标签
    Wix 打包(1)[转载]
    windows 域验证 IIS7.0
  • 原文地址:https://www.cnblogs.com/linxiu-0925/p/5408062.html
Copyright © 2020-2023  润新知