IOS 程序内调用本地打电话功能-make a phone call
2013-03-29 14:01
357 查看
利用openURL接口来调用打电话功能。代码还具备根据正则表达式判断电话好吗输入的合法性。
- (void)makeCall:(NSString *)number { NSString *txt = number; NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"[0-9]{4}[-]{0,1}[0-9]{4}?" options:NSRegularExpressionSearch error:nil]; NSTextCheckingResult *result = [regex firstMatchInString:txt options:0 range:NSMakeRange(0, [txt length])]; NSString *cleanedString = [[[txt substringWithRange:[result range]] componentsSeparatedByCharactersInSet:[[NSCharacterSet characterSetWithCharactersInString:@"0123456789-+()"] invertedSet]] componentsJoinedByString:@""]; NSString *escapedPhoneNumber = [cleanedString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSURL *telURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel://%@", escapedPhoneNumber]]; [[UIApplication sharedApplication] openURL:telURL]; }
相关文章推荐
- IOS 程序内调用本地打电话功能-make a phone call
- IOS 调用打电话,发信息,email功能
- ios 调用打电话,发短信的功能
- iOS 调用拍照、选择本地相册、上传功能---未完善。
- Android调用打电话(Call Phone)
- iOS - (调用系统本机打电话功能)
- ios 调用打电话、短信等功能
- ABAP 调用本地程序打开文件 'CALL_INTERNET_ADRESS'
- iOS开发之调用系统打电话发短信接口以及程序内发短信
- Mirror app - 调用CALL打电话功能
- iOS 调用系统发短信以及打电话功能
- iOS开发之调用系统打电话发短信接口以及程序内发短信
- iOS 开发之 调用打电话功能
- iOS 调用系统发短信以及打电话功能
- iOS开发中,调用打电话,发短信,打开网址等手机基础功能
- iOS 通讯录添加了本地打电话功能
- iOS 调用系统发短信以及打电话功能
- Windows 注册自定义的协议 实现通过网页调用本地程序的功能例如QQ等
- iOS 如何调用打电话发短信等功能
- ios 调用系统发短信以及打电话功能