zoukankan      html  css  js  c++  java
  • 每日分享 - 发送短信/邮件/打电话

    Link Address:http://www.cocoachina.com/bbs/read.php?tid=20993&fpage=3

    每日分享 - 发送短信/邮件/打电话   

     
     
    很简单的方法了

    + (void)alert:(NSString *)msg
    {
        UIAlertView *alertView = [[[UIAlertView alloc] initWithTitle:msg message:@"" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil] autorelease];
        [alertView showWithBackground];
    }

    + (NSString*) cleanPhoneNumber:(NSString*)phoneNumber
    {
        NSString* number = [NSString stringWithString:phoneNumber];
        NSString* number1 = [[[number stringByReplacingOccurrencesOfString:@" " withString:@""]
                              //                        stringByReplacingOccurrencesOfString:@"-" withString:@""]
                              stringByReplacingOccurrencesOfString:@"(" withString:@""] 
                             stringByReplacingOccurrencesOfString:@")" withString:@""];
        
        return number1;    
    }

    + (void) makeCall:(NSString *)phoneNumber
    {
        if ([DeviceDetection isIPodTouch]){
            [UIUtils alert:kCallNotSupportOnIPod];
            return;
        }
        
        NSString* numberAfterClear = [UIUtils cleanPhoneNumber:phoneNumber];    
        
        NSURL *phoneNumberURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@", numberAfterClear]];
        NSLog(@"make call, URL=%@", phoneNumberURL);
        
        [[UIApplication sharedApplication] openURL:phoneNumberURL];    
    }

    + (void) sendSms:(NSString *)phoneNumber
    {
        if ([DeviceDetection isIPodTouch]){
            [UIUtils alert:kSmsNotSupportOnIPod];
            return;
        }
        
        NSString* numberAfterClear = [UIUtils cleanPhoneNumber:phoneNumber];
        
        NSURL *phoneNumberURL = [NSURL URLWithString:[NSString stringWithFormat:@"sms:%@", numberAfterClear]];
        NSLog(@"send sms, URL=%@", phoneNumberURL);
        [[UIApplication sharedApplication] openURL:phoneNumberURL];    
    }

    + (void) sendEmail:(NSString *)phoneNumber
    {
        NSURL *phoneNumberURL = [NSURL URLWithString:[NSString stringWithFormat:@"mailto:%@", phoneNumber]];
        NSLog(@"send sms, URL=%@", phoneNumberURL);
        [[UIApplication sharedApplication] openURL:phoneNumberURL];    
    }

    + (void) sendEmail:(NSString *)to cc:(NSString*)cc subject:(NSString*)subject body:(NSString*)body
    {
        NSString* str = [NSString stringWithFormat:@"mailto:%@?cc=%@&subject=%@&body=%@",
                         to, cc, subject, body];

        str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
        
    }
  • 相关阅读:
    python操作excel文件一(xlrd读取文件)
    pytest 1.简单介绍一,安装和如何运行
    request鉴权的处理和判断
    Struts2 easy UI插件
    Struts2 JQuery UI常用插件
    Struts2 JSON
    Struts2 使用jQuery实现Ajax
    Struts2 Ajax校验
    oracle连接方式、创建数据库用户、忘记数据库密码、用户锁定
    第二次考试:错题总结
  • 原文地址:https://www.cnblogs.com/xingchen/p/2271403.html
Copyright © 2011-2022 走看看