objective-C call

来源:互联网 发布:猪肉绦虫知乎 编辑:程序博客网 时间:2024/06/05 22:58
#import <CoreTelephony/CTCallCenter.h>#import <CoreTelephony/CTCall.h>
@interface EmergencyRescuePhoneTableView ()<UITableViewDataSource,UITableViewDelegate>@property(nonatomic,strong)CTCallCenter *hwcenter;@end
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{    CTCallCenter *center = [[CTCallCenter alloc]init];    _hwcenter= center;    center.callEventHandler = ^(CTCall *call){        HWDLog(@"call:%@",call.description);        __block BOOL isCall=YES;        if ([call.callState isEqualToString:@"CTCallStateDialing"]) {            if (isCall) {               [self call];                isCall=NO;            }         }        if ([call.callState isEqualToString:@"CTCallStateDisconnected"]) {            isCall=YES;        }     };     RescueModel * model = self.dataArray[indexPath.row];     NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",model.rescuePhoneNumber]];    [[UIApplication sharedApplication] openURL:url];}


原创粉丝点击