iOS 拨打电话相关知识总结

来源:互联网 发布:批处理图片的软件 编辑:程序博客网 时间:2024/05/17 22:40

示例方法

1.貌似是私有方法,拨打电话完成后可返回应用,拨打前有提示。

NSString *strTel= [NSStringstringWithFormat:@"telprompt:13888888888"];
  [[UIApplication sharedApplication]openURL:[NSURL URLWithString:strTel]];

2.用网页加载来拨打电话,效果和第一种一样,使用没有任何问题

NSURL * url = [NSURL URLWithString:@"tel:11111111"];

[webView loadRequest:[NSURLRequest requestWithURL:url]];

3.普通方法,直接拨打,打完回不到应用,回到系统拨号界面

NSString *strTel= [NSStringstringWithFormat:@"tel:13888888888"];

[[UIApplication sharedApplication] openURL:[NSURLURLWithString:strTel]];

 

相关问题:

1.特殊号码拨打失败

[[UIApplication sharedApplication] openURL:[NSURLURLWithString:@"tel://*111*12371#]];

 

相关库 CoreTelephony

这个里面有一个Demo(CoreTelephonyDemo:file:///Users/shjborage/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS5_0.iOSLibrary.docset/Contents/Resources/Documents/index.html#samplecode/CoreTelephonyDemo/Introduction/Intro.html)

 

所有相关链接:file:///Users/shjborage/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS5_0.iOSLibrary.docset/Contents/Resources/Documents/index.html#featuredarticles/iPhoneURLScheme_Reference/Introduction/Introduction.html#//apple_ref/doc/uid/TP40007899

 

Organization of This Document

Each article in this document describes the format of aparticular type of URL:

“Mail Links” describes the format for sending email with theMail application.(mailto:frank@wwdcdemo.example.com)
“Phone Links” describes the format for dialing phone numbers in thePhone application.(tel:1-408-555-5555)
“Text Links” describes the format for launching the Textapplication.(

sms:
sms:1-408-555-1212


“Map Links” describes the format for specifying locations in theMaps application.(http://maps.google.com/maps?daddr=San+Francisco,+CA&saddr=cupertino http://maps.google.com/maps?q=cupertino)
“YouTube Links” describes the format for linking to YouTubevideos.(http://www.youtube.com/v/VIDEO_IDENTIFIER)
“iTunes Links” describes the format for linking to items in theiTunes Music Store.(http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewAlbum?i=156093464&id=156093462&s=143441)

 

转一下别人写的:

在iPhone中,可以直接用UIApp打开URL地址。如下所示:

[ UIApp openURL: [ NSURL URLWithString:@"http://www.apple.com"] ];
或者:

[ UIApp openURL: [ NSURLURLWithString:@"mailto:apple@mac.com?Subject=hello" ] ];
 

与此同时,iPhone还包含一些其他除了http://或者mailto:之外的URL:

sms:// 可以调用短信程序

tel:// 可以拨打电话

itms:// 可以打开MobileStore.app

audio-player-event:// 可以打开iPod

audio-player-event://?uicmd=show-purchased-playlist可以打开iPod播放列表

video-player-event:// 可以打开iPod中的视频



个人项目中使用实例:(使用了SQLibs,请查看相关博文)

           UIDevice*device = [UIDevicecurrentDevice];

          NSString *strModel = [devicemodel];

          if ([strModel hasPrefix:@"iPhone"]) {

              NSString *strTel= [NSString stringWithFormat:@"tel:%@", kServiceTel];

              if (_wvTel == nil)

                 _wvTel =[[UIWebView alloc] initWithFrame:CGRectZero];

                       [_wvTelloadRequest:[NSURLRequest requestWithURL:[NSURLURLWithString:strTel]]];

           }else {

                       [[SQAlertViewdefaultAlert] alert:[NSString localizedString:@"AlertTitle_Default"]

                                  message:[NSString localizedString:@"AlertTitle_NotSupport"]];

           }

0 0
原创粉丝点击