iOS关于拨打电话和发送短信的用法
2015-01-14 00:00
441 查看
在做开发的过程中会经常遇到一些要调用拨号和发短信的功能。这里整理了一下。
1,首先来看看发短信,直接上代码
说明一下,手机号码放在phoneArray数组里,如果需要给多人发送短信的话就比较方便了。text里就是要发送短信的内容
2,拨号
这个方法拨号前会自动弹框让你选择是否确定拨号,拨号结束后会返回到你的当前的程序
3,拨号
这个方法的拨号不会弹框提醒你让你确定是否确定拨号,而是直接拨号,并且拨号结束后停留在系统自带的通话记录里。不会返回到之前的程序。
1,首先来看看发短信,直接上代码
NSArray *phoneArray = [NSArray arrayWithObjects:@"18212341234", nil]; NSString *text = [NSString stringWithFormat:@"这是测试短信,收到请勿回复"]; [self sendSMS:text recipientList:phoneArray];
说明一下,手机号码放在phoneArray数组里,如果需要给多人发送短信的话就比较方便了。text里就是要发送短信的内容
2,拨号
NSString *phone = @"18212341234"; UIWebView *callWebview =[[UIWebView alloc] init]; NSString *telUrl = [NSString stringWithFormat:@"tel:%@",phone]; NSURL *url = [[NSURL alloc] initWithString:telUrl]; [callWebview loadRequest:[NSURLRequest requestWithURL:url]]; [self.view addSubview:callWebview];
这个方法拨号前会自动弹框让你选择是否确定拨号,拨号结束后会返回到你的当前的程序
3,拨号
NSString *phoneString = @"18212341234"; UIWebView *callWebview =[[UIWebView alloc] init]; NSString *telUrl = [NSString stringWithFormat:@"tel:%@",phoneString]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:telUrl]]; [self.view addSubview:callWebview];
这个方法的拨号不会弹框提醒你让你确定是否确定拨号,而是直接拨号,并且拨号结束后停留在系统自带的通话记录里。不会返回到之前的程序。
相关文章推荐
- iOS 拨打电话 发送短信
- iOS开发中调用网址、拨打电话、发送短信、发送邮件
- iOS 中获得本机号,拨打电话,发送短信
- iOS 点击按钮实现拨打电话,发送短信功能
- iOS应用调用手机发送短信和拨打电话
- IOS开发之_短信发送与拨打电话
- iOS_拨打电话/发送短信
- ios调用本地拨打电话,发送短信
- IOS中调用系统拨打电话发送短信
- IOS中调用系统拨打电话与发送短信
- iOS程序中调用系统自带应用(短信,邮件,浏览器,地图,appstore,拨打电话)
- 转 iOS程序中调用系统自带应用(短信,邮件,浏览器,地图,appstore,拨打电话)
- iOS程序中调用系统自带应用(短信,邮件,浏览器,地图,appstore,拨打电话)
- 命令行方式向Android模拟器发送短信和拨打电话
- 黑莓开发中的拨打电话和发送短信函数
- android中拨打电话和短信发送的实现
- iOS程序中调用系统自带应用(短信,邮件,浏览器,地图,appstore,拨打电话)
- android拨打电话和发送短信核心代码
- 如何在模拟器上向android发送短信和拨打电话?