• ios电话监听状态


    #import "ViewController.h"

    #import <CoreTelephony/CTCallCenter.h>

    #import <CoreTelephony/CTCall.h>

    @interface ViewController ()

    @property (nonatomic, strong) CTCallCenter *center;

    @property (nonatomic, strong) UIWebView * callView;

    @end

    @implementation ViewController

    - (void)viewDidLoad {

        [super viewDidLoad];

        UIButton * btn = [[UIButton alloc]initWithFrame:CGRectMake(50, 50, 150, 50)];

        btn.backgroundColor = [UIColor redColor];

        [btn setTitle:@"拨打电话" forState:UIControlStateNormal];

        [btn addTarget:self action:@selector(callBack) forControlEvents:UIControlEventTouchUpInside];

        [self.view addSubview:btn];

        

        _center = [[CTCallCenter alloc] init];

        _center.callEventHandler = ^(CTCall *call) {

            if ([call.callState isEqualToString:CTCallStateDisconnected])

            {

                NSLog(@"挂断了电话咯Call has been disconnected");

            }

            else if ([call.callState isEqualToString:CTCallStateConnected])

            {

                NSLog(@"电话通了Call has just been connected");

            }

            else if([call.callState isEqualToString:CTCallStateIncoming])

            {

                NSLog(@"来电话了Call is incoming");

                

            }

            else if ([call.callState isEqualToString:CTCallStateDialing])

            {

                NSLog(@"正在播出电话call is dialing");

            }

            else

            {

                NSLog(@"嘛都没做Nothing is done");

            }

        };

        // Do any additional setup after loading the view, typically from a nib.

    }

    - (void)callBack{

        NSString * str=[[NSString alloc] initWithFormat:@"tel:%@",@"183****1773"];

        UIWebView * callWebview = [[UIWebView alloc] init];

        [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];

        [self.view addSubview:callWebview];

    }

    - (void)didReceiveMemoryWarning {

        [super didReceiveMemoryWarning];

        // Dispose of any resources that can be recreated.

    }

    @end

  • 相关阅读:
    合数分解为质数的乘积模板
    P2626 斐波那契数列(升级版)(合数的质数分解, 大数为素数的概率十分小的利用)
    1305 Pairwise Sum and Divide
    1344 走格子 (前缀和)
    1347 旋转字符串
    E
    pek (北大oj)3070
    数学中各种矩阵收集(转至其他博主)
    (数论)逆元的线性算法
    洛谷P2627 修剪草坪 题解 单调队列优化DP
  • 原文地址:https://www.cnblogs.com/sunfuyou/p/6164962.html
Copyright © 2020-2023  润新知