zoukankan      html  css  js  c++  java
  • iphone 拨打电话的 两种方法-备

    大家想不想在自己的应用中拨打电话呀?打电话可以用openURL:这个API, 如:[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://10086"]];但是当电话结束后,返回的是系统的拨打电话界面,如何才能返回自己的应用呢?这儿有两种方法与大家分享。

    第一种是用UIWebView加载电话,这种是合法的,可以上App Store的。

    代码如下:

    1. // assuming you have an ivar to store a weak reference to a UIWebView:  
    2. // UIWebView *phoneCallWebView;  
    3. - (void) dialPhoneNumber:(NSString *)aPhoneNumber  
    4. {  
    5.     NSURL *phoneURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",aPhoneNumber]];  
    6.     if ( !phoneCallWebView ) {          
    7.         phoneCallWebView = [[UIWebView alloc] initWithFrame:CGRectZero];  
    8.     }  
    9.     [phoneCallWebView loadRequest:[NSURLRequest requestWithURL:phoneURL]];  
    10. }  
    11. - (void) dealloc  
    12. {  
    13.     // cleanup  
    14.     [phoneCallWebView release], phoneCallWebView = nil;  
    15.    [super dealloc];  
    16. }  

    第二种是私有方法,不能上App Store的。

    1. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"telprompt://10086"]];  
  • 相关阅读:
    Cookie基本使用
    Chartlet简单易用的图表控件
    JQuery 基础:6.Each的用法
    图的基本算法
    Head First Design Patterns Strategy Pattern
    个人整理的面试题
    Android从SIM卡中获取联系人
    Android 覆盖安装
    Head First Design Patterns Adapter Pattern
    android 获取sim卡运营商信息(转)
  • 原文地址:https://www.cnblogs.com/isItOk/p/5228089.html
Copyright © 2011-2022 走看看