当前位置:编程学习 > wap >>

iphone应用开发之十:发送短信/邮件/打电话

 

+ (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]];   

       

}     

 


作者 andy-清风
补充:移动开发 , IOS ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,