zoukankan      html  css  js  c++  java
  • IOS-电话和短信功能

    打电话可以用openURL:这个API, 如:[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://10086"]];

    但是当电话结束后,返回的是系统的拨打电话界面,如何才能返回自己的应用呢?这儿有两种 方法与大家分享。

    第一种是用UIWebView加载电话,这种是合法的,可以上App Store的。
    代码如下:
    // assuming you have an ivar to store a weak reference to a UIWebView:  
    // UIWebView *phoneCallWebView;  
    - (void) dialPhoneNumber:(NSString *)aPhoneNumber  
    {  
        NSURL *phoneURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",aPhoneNumber]];  
        if ( !phoneCallWebView ) {          
            phoneCallWebView = [[UIWebView alloc] initWithFrame:CGRectZero];  
        }  
        [phoneCallWebView loadRequest:[NSURLRequest requestWithURL:phoneURL]];  
    }  
    - (void) dealloc  
    {  
        // cleanup  
        [phoneCallWebView release], phoneCallWebView = nil;  
       [super dealloc];  
    }  


    第二种是私有方法,不能上App Store的。
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"telprompt://10086"]]; 

    iOS4.0新加入了MFMessageComposeViewController和MFMessageComposeViewControllerDelegate,提供了发送短信的接口,可以像发送邮件那样不用跳出程序来发送短信. 介绍可参阅Message UI。相关网址:http://blog.csdn.net/rhljiayou/article/details/7929813

  • 相关阅读:
    不要在构造中做太多事情,不然有时候会出现有意思的代码~
    对称加密和非对称加密
    关于WebAPI安全认证的问题
    Dojo和jQuery区别
    跨域访问解决方案:JSONP
    MyEclipse中提示SpringMVC的XML配置文件出错解决方法
    什么是跨域请求
    Hadoop的初步理解
    数据库读写分离的初步理解
    前端渲染和后端渲染
  • 原文地址:https://www.cnblogs.com/jhonyzhang/p/3653790.html
Copyright © 2011-2022 走看看