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 ...
随机推荐
- 1092. To Buy or Not to Buy (20)
Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy ...
- [原创]PostgreSQL中十进制、二进制、十六进制之间的相互转换
在PostgreSQL中,二进制.十进制.十六进制之间的转换是非常方便的,如下: 十进制转十六进制和二进制 mydb=# SELECT to_hex(10); to_hex -------- a (1 ...
- hdu 3282 Running Median
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=3282 Running Median Description For this problem, you ...
- 海蜘蛛ISPV6.1.5,目前破解版本中最稳定的!
海蜘蛛ISPV6.1.5,目前破解版本中最稳定的! 破解步骤如下: 一.安装完毕进控制台 二.使用muddyboot登陆 密码(123456) 三.输入root回车 四.输入regtools回车 五. ...
- 联想Z470安装10.11懒人版成功!!特此分享!!
折腾黑苹果也断断续续好几个月了,在远景也爬了好多贴,遇到问题基本上靠自己解决,自己组的台式机已基本完美,大学期间买的联想Z470现在是“食之无味,弃之可惜”,想想也来试试装个黑苹果玩玩,之前装过10. ...
- 【EF Code First】CodeFirst初始配置
1,在Nuget管理中下载EntityFramework 2,配置文件中添加数据库配置 <connectionStrings> <add name="DefaultConn ...
- Swift global function(count indexOfObject contains...)
当你在使用Swift时会发现一些常用的函数不!见!了! 比如 String: s.count() s.contains() Array: a.indexOfObeject(t:<T> ...
- svn中的图标解释
黄色感叹号(有冲突): --这是有冲突了,冲突就是说你对某个文件进行了修改,别人也对这个文件进行了修改,别人抢在你提交之前先提交了,这时你再提交就会被提示发生冲突,而不 允许你提交,防止你的提交覆盖了 ...
- 如何使用css和jquery控制文章标题字数?
如何使用css控制文章标题字数? 最佳答案 控制文章标题字数,不是动态网页的专利,如果静态页面使用CSS样式,也可以实现相同的效果! 看这个例子,你们可以复制到记事本保存为HTML文件看效果! < ...
- 网件无线网卡在windows 2012支持问题
网件的无线网卡的驱动是支持windows 8.1的,但是安装了驱动后,却没法启动网卡.网上搜索后发现,service里面网件有一进程没法启动:而2012年忘记官方论坛技术支持答复咨询居然说,网件驱动不 ...