//调用自带mail
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://admin@hzlzh.com"]]; //调用电话
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8008808888"]]; //调用sms
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://800888"]]; //调用打开网址
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.baidu.com"]];

调用phone可以传递号码,调用SMS 只能设定号码,不能初始化SMS内容。

发短信邮件需要的框架

导入头文件#import <MessageUI/MessageUI.h>

协议:<MFMailComposeViewControllerDelegate,MFMessageComposeViewControllerDelegate>

//点击按钮后,触发这个方法
-(void)sendEMail
{
MFMailComposeViewController *mailPicker = [[MFMailComposeViewController alloc] init]; mailPicker.mailComposeDelegate = self; //设置主题
[mailPicker setSubject: @"eMail主题"]; // 添加发送者
NSArray *toRecipients = [NSArray arrayWithObject: @"first@example.com"]; [mailPicker setToRecipients: toRecipients]; // 添加图片
UIImage *addPic = [UIImage imageNamed: @"ios.jpg"];
NSData *imageData = UIImagePNGRepresentation(addPic); // png
// NSData *imageData = UIImageJPEGRepresentation(addPic, 1); // jpeg
[mailPicker addAttachmentData: imageData mimeType: @"" fileName: @"ios.jpg"]; NSString *emailBody = @"eMail 正文";
[mailPicker setMessageBody:emailBody isHTML:YES]; [self presentViewController:mailPicker animated:YES completion:nil];
} - (void)sendSMS{
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init]; if([MFMessageComposeViewController canSendText])
{
controller.body = @"";
controller.recipients = @[@"",@""];
controller.messageComposeDelegate = self; [self presentViewController:controller animated:YES completion:nil];
}
} #pragma mark - <MFMessageComposeViewControllerDelegate> // 处理发送完的响应结果
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil]; if (result == MessageComposeResultCancelled){
NSLog(@"Message cancelled");
} else if (result == MessageComposeResultSent){
NSLog(@"Message sent");
} else{
NSLog(@"Message failed");
}
} #pragma mark - <MFMailComposeViewControllerDelegate> - (void)mailComposeController:(MFMailComposeViewController *)controller
didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
NSString *msg; switch (result)
{
case MFMailComposeResultCancelled:
msg = @"邮件发送取消";
break;
case MFMailComposeResultSaved:
msg = @"邮件保存成功"; break;
case MFMailComposeResultSent:
msg = @"邮件发送成功"; break;
case MFMailComposeResultFailed:
msg = @"邮件发送失败"; break;
default:
break;
}
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
}
 

iOS打电话,发短信,发邮件,打开网址的更多相关文章

  1. ios 设置亮度、声音;调用发短信、邮件、打电话

    一,设置亮度 [[UIScreen mainScreen] setBrightness:0.5];//0.0~1.0 二,设置声音 1,添加 MediaPlayer.framework 框架 2,在需 ...

  2. Android实例-打电话、发短信和邮件,取得手机IMEI号(XE8+小米2)

    结果: 1.不提示发短信卡住,点击没有反映,我猜想,可能是因为我用的是小米手机吧. 2.接收短信报错,我猜想可能是我改了里面的方法吧(哪位大神了解,求指教). 3.project -->opti ...

  3. iOS 打电话、发短信、邮件、打开网址、调用应用等合集

    iOS中的很多功能都是非常简单的,几行代码就搞定了,比如打电话.打开网址.发邮件.发短信等,这里总结几个比较常用的: 1.打电话 方式一:最简单最直接的方式:直接跳到拨号界面 NSURL *url = ...

  4. 打电话,发短信,发邮件,app跳转

    1.打电话 - (IBAction)callPhone1:(id)sender { NSURL *url = [NSURL URLWithString:@"tel://18500441739 ...

  5. h5打电话发短信写邮件怎么实现

    // 一.打电话<a href="tel:0755-10086">打电话给:0755-10086</a> // 二.发短信,winphone系统无效< ...

  6. a链接 打电话 发短信 发email

    <a href="tel:10086">给10086打电话</a><a href="sms:10086">给10086发短信 ...

  7. iOS开发——发短信,邮件

    在IOS开发中,有时候我们会需要用到邮件发送的功能.比如,接收用户反馈和程序崩溃通知等等,这个功能是很常用的.在苹果系统中,如果彼此的手机都是iOS设备,并且开通了iMessage功能,那么彼此之间的 ...

  8. ios-王云鹤 调用ios系统功能---------------打电话、发短信、发邮件

    --------------------------------------菜鸟总结,欢迎读者雅正------------------------------------------------- 先 ...

  9. iOS中多种方式实现打电话、发短信、写邮件

    一.打电话 打电话--方法1 NSURL *URL = [NSURL URLWithString:@"tel://10010"]; [[UIApplication sharedAp ...

  10. iOS openURL方法实现打电话、发短信、发邮件、打开其他App

    UIApplication有个功能十分强大的openURL:方法 - (BOOL)openURL:(NSURL*)url; 通过这个方法,我们可以实现: 先获取 UIApplication UIApp ...

随机推荐

  1. uva 11186 Circum Triangle<叉积>

    链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  2. Go字符串函数

    下面的代码中,列出了Go官方包中常见的字符串函数. package main import s "strings" import "fmt" //为打印函数起个 ...

  3. 在DNS管理器——用局域网IP指定你所起的域名名称

    在服务器上面,进行以下相关的操作: 第一步:打开DNS管理器; 第二步:在“正向查找区域”添加域名为:icanyin.net; 第三步:添加主机pm,将域名pm.icanyin.net解析为IP地址: ...

  4. Web中Listener的创建

    使用Listener只需要两个步骤: 定义Listener实现类. 通过Annotation或在web.xml文件中配置Listener 实现Listener类 监听不同Web事件的监听器不相同,常用 ...

  5. P1233: [Usaco2009Open]干草堆tower

    这道题,首先想到的就两个,一是贪心,二是动规,然而 1<=N<=100000;1<=w_i<=10000 的数据范围实在不敢恭维,所以说第一想法是错的.仔细一想,首先,我们需要 ...

  6. html转义函数

    public static String filter(String message) { if (message == null) return (null); char content[] = n ...

  7. DF与EF的区别

    DF:专有文件 EF:基本文件 1.EF没有文件名,只有FID(文件标识符) 2.DF有文件名,又有FID,因此COS可以根据文件名来访问DF

  8. linux下搭建mysql主从

    在master上创建repl账户,用于复制. grant replication slave on *.* to 'repl'@'%' identified by 'P@$$W0rd'; flush ...

  9. Vim实用命令

    [n]yy:从当前行复制n行 [n]p:粘贴n次 [n]dd:删除当前行往下的n行 /  : 向后查找 ?:向前查找 u → undo 撤销上一操作 <C-r> → redo 0 → 开启 ...

  10. 安装Windows7出现:”安装程序无法创建新的系统分区 也无法定位系统分区“ 终极解决方案

    参考:地址 解决方法: 1.先格式化一下你要装的那个盘,然后,拔出U盘,啥也别动,只拔出U盘就行,再装上U盘,然后刷新一下[选硬盘那里的高级选项中有格式化和刷新],再选择要安装的硬盘点下一步,OK了, ...