NSString *callPhone = [NSString stringWithFormat:@"telprompt://%@",@"183 0522 3025"];
NSURL *url = [NSURL URLWithString:callPhone];
打不出去你敢信么????哈哈哈哈。。。
真的是特别诡异特别诡异诡异啊!!!!!!!!
机智如我呢~~~把里面的东西都去掉,然后只留下数字总行了吧。。
- (void)btnc {
NSString *str = [self xxfilterCharactor:@"[^0-9]" str:@"183 0522 3025"];
NSString *callPhone = [NSString stringWithFormat:@"tel:%@",str];
NSURL *url = [NSURL URLWithString:callPhone];
[[UIApplication sharedApplication] openURL:url options:[NSDictionary dictionary] completionHandler:^(BOOL success) {
}];
}
- (NSString *)xxfilterCharactor:(NSString *)filter str:(NSString *)str{
NSString *filterText = str;
NSError *error = NULL;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:filter options:NSRegularExpressionCaseInsensitive error:&error];
NSString *result = [regex stringByReplacingMatchesInString:filterText options:NSMatchingReportCompletion range:NSMakeRange(0, str.length) withTemplate:@""];
return result;
}
虽然机智的解决了问题,但是我不知道为什么。。
网友评论