iOS打电话,发短信,发邮件,打开网址
//调用自带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打电话,发短信,发邮件,打开网址的更多相关文章
- ios 设置亮度、声音;调用发短信、邮件、打电话
一,设置亮度 [[UIScreen mainScreen] setBrightness:0.5];//0.0~1.0 二,设置声音 1,添加 MediaPlayer.framework 框架 2,在需 ...
- Android实例-打电话、发短信和邮件,取得手机IMEI号(XE8+小米2)
结果: 1.不提示发短信卡住,点击没有反映,我猜想,可能是因为我用的是小米手机吧. 2.接收短信报错,我猜想可能是我改了里面的方法吧(哪位大神了解,求指教). 3.project -->opti ...
- iOS 打电话、发短信、邮件、打开网址、调用应用等合集
iOS中的很多功能都是非常简单的,几行代码就搞定了,比如打电话.打开网址.发邮件.发短信等,这里总结几个比较常用的: 1.打电话 方式一:最简单最直接的方式:直接跳到拨号界面 NSURL *url = ...
- 打电话,发短信,发邮件,app跳转
1.打电话 - (IBAction)callPhone1:(id)sender { NSURL *url = [NSURL URLWithString:@"tel://18500441739 ...
- h5打电话发短信写邮件怎么实现
// 一.打电话<a href="tel:0755-10086">打电话给:0755-10086</a> // 二.发短信,winphone系统无效< ...
- a链接 打电话 发短信 发email
<a href="tel:10086">给10086打电话</a><a href="sms:10086">给10086发短信 ...
- iOS开发——发短信,邮件
在IOS开发中,有时候我们会需要用到邮件发送的功能.比如,接收用户反馈和程序崩溃通知等等,这个功能是很常用的.在苹果系统中,如果彼此的手机都是iOS设备,并且开通了iMessage功能,那么彼此之间的 ...
- ios-王云鹤 调用ios系统功能---------------打电话、发短信、发邮件
--------------------------------------菜鸟总结,欢迎读者雅正------------------------------------------------- 先 ...
- iOS中多种方式实现打电话、发短信、写邮件
一.打电话 打电话--方法1 NSURL *URL = [NSURL URLWithString:@"tel://10010"]; [[UIApplication sharedAp ...
- iOS openURL方法实现打电话、发短信、发邮件、打开其他App
UIApplication有个功能十分强大的openURL:方法 - (BOOL)openURL:(NSURL*)url; 通过这个方法,我们可以实现: 先获取 UIApplication UIApp ...
随机推荐
- 自己写算法---java的堆的非递归遍历
import java.io.*; import java.util.*; public class Main { public static void main(String args[]) { S ...
- shelll函数求两个输入数字之和
#!/bin/bash #This is a test of the addition of the program! function AddFun { read -p "Enter a ...
- hdu 2579 Dating with girls(2)
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2579 Dating with girls(2) Description If you have sol ...
- linux安装ruby
可以使用 sudo apt-get install ruby 的方式安装,但一般这种方式安装的版本比较旧.另外也可以用以下方式安装新的版本. 1. 首先更新软件源,使用国内的.参考:http://wi ...
- Golang的iota的特性
Golang的iota的特性: 1. iota在每个ConstBlock中自动归0. 2. iota在每个ConstSpec后自动增1. 换言之: iota是ConstBlock中ConstSpec的 ...
- Android or iOS 运行 meteor App 屏幕一片空白 White screen的解决方法
在mac上出现这种错误,多是与文件夹的权限有关,有人建议把~/.meteor目录删除,重新下载安装.在墙内重新下载安装的代价非常之大. 简单的解决方法,便是把~/.meteor,以及当前项目目录的权限 ...
- vs2010 开发过程中调试时 有错误不中断
出现这个的原因是调试的设置有问题,修改下设置就好了. 修改方法:点击上边工具栏中 调试--异常 出现以下页面,把引发那列复选框全部勾上,点击确定就好了.
- 2.2孙鑫C++
1.继承 动物有 吃 睡 呼吸的方法 当然 鱼也有 不用重复再定义 1)public 那里都可以访问 #include <iostream.h> class Animal //类 基 ...
- Hibernate从入门到精通(十)多对多单向关联映射
上一篇文章Hibernate从入门到精通(九)一对多双向关联映射中我们讲解了一下关于一对多关联映射的相关内容,这次我们继续多对多单向关联映射. 多对多单向关联映射 在讲解多对多单向关联映射之前,首先看 ...
- Mono for Android (1) 之布局
最近和同事交接工作,首次接触mono for android, 结果画view时少了layout,页面没办法出来,各种冥思,各种找问题,最后把关于布局的一些共享出来(同事写的,哈哈): Andro ...