打电话、发短信、发邮件常用代码
2015-09-16 14:23
399 查看
(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]];
}
{
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]];
}
相关文章推荐
- 使用PHP ping域名或IP
- Asp.Net获取GridView当前行的方法
- python日积月累之ljust()
- springMVC注解优化
- python bz2模块
- JDK源码阅读之ListIterator接口
- spring MVC hibernate 多对一 传输JSON问题
- Log4j2 使用示例
- 利用matlab获取算法源代码
- Java学习笔记02 Java语法基础
- Lua基础
- java通用抹去魔,在边界行动,擦除补偿
- python日积月累之join()
- Asp编码优化技巧
- C语言算法小练习-1
- 使用Eclipse搭建Android开发环境
- FTP上传下载
- django 1.8 官方文档翻译:8-5 加密签名
- python 进程间通信
- php二维数组去重