官方代码

发短息和邮件添加MessageUI.framework 库

发送信息

- (IBAction)showSMSPicker:(id)sender

{

// You must check that the current device can send SMS messages before you

// attempt to create an instance of MFMessageComposeViewController.  If the

// device can not send SMS messages,

// [[MFMessageComposeViewController alloc] init] will return nil.  Your app

// will crash when it calls -presentViewController:animated:completion: with

// a nil view controller.

if ([MFMessageComposeViewControllercanSendText])

// The device can send email.

{

[selfdisplaySMSComposerSheet];

}

else

// The device can not send email.

{

self.feedbackMsg.hidden =NO;

self.feedbackMsg.text = @"Device not configured to send SMS.";

}

- (void)displaySMSComposerSheet

{

MFMessageComposeViewController *picker = [[MFMessageComposeViewControlleralloc] init];

picker.messageComposeDelegate =self;

picker.navigationBar.tintColor = [UIColorblackColor];

picker.recipients = [NSArrayarrayWithObject:@"186888888"];

picker.body =@"Hello from California!";

[selfpresentViewController:picker animated:YEScompletion:NULL];

}

// -------------------------------------------------------------------------------

// messageComposeViewController:didFinishWithResult:

//  Dismisses the message composition interface when users tap Cancel or Send.

//  Proceeds to update the feedback message field with the result of the

//  operation.

// -------------------------------------------------------------------------------

- (void)messageComposeViewController:(MFMessageComposeViewController *)controller

didFinishWithResult:(MessageComposeResult)result

{

self.feedbackMsg.hidden =NO;

// Notifies users about errors associated with the interface

switch (result)

{

caseMessageComposeResultCancelled:

self.feedbackMsg.text = @"Result: SMS sending canceled";

break;

caseMessageComposeResultSent:

self.feedbackMsg.text = @"Result: SMS sent";

break;

caseMessageComposeResultFailed:

self.feedbackMsg.text = @"Result: SMS sending failed";

break;

default:

self.feedbackMsg.text = @"Result: SMS not sent";

break;

}

[selfdismissViewControllerAnimated:YEScompletion:NULL];

}

发送邮件

- (IBAction)showMailPicker:(id)sender

{

// You must check that the current device can send email messages before you

// attempt to create an instance of MFMailComposeViewController.  If the

// device can not send email messages,

// [[MFMailComposeViewController alloc] init] will return nil.  Your app

// will crash when it calls -presentViewController:animated:completion: with

// a nil view controller.

if ([MFMailComposeViewControllercanSendMail])

// The device can send email.

{

[selfdisplayMailComposerSheet];

}

else

// The device can not send email.

{

self.feedbackMsg.hidden =NO;

self.feedbackMsg.text =@"Device not configured to send mail.";

}

}

#pragma mark - Compose Mail/SMS

// -------------------------------------------------------------------------------

// displayMailComposerSheet

//  Displays an email composition interface inside the application.

//  Populates all the Mail fields.

// -------------------------------------------------------------------------------

- (void)displayMailComposerSheet

{

MFMailComposeViewController *picker = [[MFMailComposeViewControlleralloc] init];

picker.mailComposeDelegate =self;

[picker setSubject:@"Hello from California!"];

// Set up recipients

NSArray *toRecipients = [NSArrayarrayWithObject:@"first@example.com"];

NSArray *ccRecipients = [NSArrayarrayWithObjects:@"second@example.com",@"third@example.com", nil];

NSArray *bccRecipients = [NSArrayarrayWithObject:@"fourth@example.com"];

[picker setToRecipients:toRecipients];

[picker setCcRecipients:ccRecipients];

[picker setBccRecipients:bccRecipients];

// Attach an image to the email

NSString *path = [[NSBundlemainBundle] pathForResource:@"rainy"ofType:@"jpg"];

NSData *myData = [NSDatadataWithContentsOfFile:path];

[picker addAttachmentData:myData mimeType:@"image/jpeg"fileName:@"rainy"];

// Fill out the email body text

NSString *emailBody =@"It is raining in sunny California!";

[picker setMessageBody:emailBody isHTML:NO];

[selfpresentViewController:picker animated:YEScompletion:NULL];

}

#pragma mark - Delegate Methods

// -------------------------------------------------------------------------------

// mailComposeController:didFinishWithResult:

//  Dismisses the email composition interface when users tap Cancel or Send.

//  Proceeds to update the message field with the result of the operation.

// -------------------------------------------------------------------------------

- (void)mailComposeController:(MFMailComposeViewController*)controller

didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error

{

self.feedbackMsg.hidden =NO;

// Notifies users about errors associated with the interface

switch (result)

{

caseMFMailComposeResultCancelled:

self.feedbackMsg.text = @"Result: Mail sending canceled";

break;

caseMFMailComposeResultSaved:

self.feedbackMsg.text = @"Result: Mail saved";

break;

caseMFMailComposeResultSent:

self.feedbackMsg.text = @"Result: Mail sent";

break;

caseMFMailComposeResultFailed:

self.feedbackMsg.text = @"Result: Mail sending failed";

break;

default:

self.feedbackMsg.text = @"Result: Mail not sent";

break;

}

[selfdismissViewControllerAnimated:YEScompletion:NULL];

}

打电话 我只写了一种简单的方式 还有其他的

添加  AddressBookUI.framework 库

#import <AddressBook/AddressBook.h>

#import <AddressBook/ABMultiValue.h>

#import <AddressBook/ABRecord.h>

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath

{

NSString *key = [keyArrayobjectAtIndex:indexPath.row];

NSArray *array = [tableDataDictionaryobjectForKey:key];

NSString *phoneNum = [arrayobjectAtIndex:1];//电话号码

NSURL *phoneURL = [NSURLURLWithString:[NSString stringWithFormat:@"tel:%@",phoneNum]];

if ( !_phoneCallWebView ) {

_phoneCallWebView = [[UIWebViewalloc] initWithFrame:CGRectZero];

}

[_phoneCallWebViewloadRequest:[NSURLRequest requestWithURL:phoneURL]];

}

iOS 打电话 发短信(转载)的更多相关文章

  1. iOS - 打电话, 发短信

    电话.短信是手机的基础功能,iOS中提供了接口,让我们调用.这篇文章简单的介绍一下iOS的打电话.发短信在程序中怎么调用. 1.打电话 [[UIApplication sharedApplicatio ...

  2. ios打电话发短信接口

    电话.短信是手机的基础功能,iOS中提供了接口,让我们调用.这篇文章简单的介绍一下iOS的打电话.发短信在程序中怎么调用. 1.打电话 [[UIApplication sharedApplicatio ...

  3. 向android模拟器打电话发短信的简单方法

    在开发android应用程序时,有时候需要测试一下向android手机拨打电话发送短信时该应用程序的反应.譬如编写一个广播接收器,来提示用户有短信收到或者处理短信,就需要向该手机发送短信来进行测试.这 ...

  4. iOS开发之调用系统打电话发短信接口以及程序内发短信

    在本篇博客开头呢,先说一下写本篇的博客的原因吧.目前在做一个小项目,要用到在本应用程序内发验证码给其他用户,怎么在应用内发送短信的具体细节想不大起来了,于是就百度了一下,发现也有关于这方面的博客,点进 ...

  5. iOS开发中打电话发短信等功能的实现

    在APP开发中,可能会涉及到打电话.发短信.发邮件等功能.比如说,通常一个产品的"关于"页面,会有开发者的联系方式,理想情况下,当用户点击该电话号码时,能够自动的帮用户拨出去,就涉 ...

  6. IOS,发短信,发邮件,打电话

    今天把APP里常用小功能 例如发短信.发邮件.打电话.全部拿出来简单说说它们的实现思路. 1.发短信实现打电话的功能,主要二种方法,下面我就分别说说它们的优缺点.1.1.发短信(1)——URL // ...

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

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

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

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

  9. WEB 移动网站 手机点击 打电话 发短信

    原文地址: http://www.blesswe.com/portal.php?mod=view&aid=428 我们在手机浏览网页是希望用户看到手机号码点击就可以直接打电话或发短信,下面我们 ...

随机推荐

  1. 线程隔离ThreadLocal

    ThreadLocal是什么 早在JDK 1.2的版本中就提供java.lang.ThreadLocal,ThreadLocal为解决多线程程序的并发问题提供了一种新的思路.使用这个工具类可以很简洁地 ...

  2. myeclipse编译问题

    这个问题困扰了两天,在用springmvc编写Controller层的时候.我前台js跳转时@RequestMapping无法捕获到,但是之前的编写的都可以捕获正常执行.然后我更改js的跳转地址,发现 ...

  3. C#中Thread与ThreadPool的比较

    最近同事在编写一个基于UPD RTP协议的通信软件,在处理接收Listen时,发现了一个问题到底是用Thread还是ThreadPool呢? 我看同事的问题比较有典型性,还是做以整理培训一下吧 Thr ...

  4. Dev 13.2 汉化教程(提供汉化cs文件下载)

    主要为了汉化 FindPanel里的Find和Clear控件名称,研究了一些时间. 废话不说.直接上干货. 1.已将cs文件分享,下载放到项目里. 下载链接: http://pan.baidu.com ...

  5. 011-Scala中的apply实战详解

    011-Scala中的apply实战详解 object中的apply方法 class中的apply方法 使用方法 apply方法可以应用在类或者Object对象中 class类 必须要创建实例化的类对 ...

  6. c语言计算矩阵特征值和特征向量-1(幂法)

    #include <stdio.h> #include <math.h> #include <stdlib.h> #define M 3 //方阵的行数 列数 #d ...

  7. aspx在页面跳转(Response.Redirect)时丢失session问题及解决办法

    [问题描述] 假设a.aspx.cs页面保存有Session["empid"]="3",当a.aspx.cs通过Response.Redirect(" ...

  8. 记AppStore 被打回的经历

    在快驰已然有半年时间之久. 见证了“快货运”产品,在不断摧残的环境中成长着.  两个人,将一个产品亲手从无到有的构建,有过心酸.有过累和有过憔悴,但当“快货运”开始上APP store时,又让人觉得开 ...

  9. 常用js字符串方法学习总结

    2016-06-15 js数组和字符串方法有很多,并且有一部分在使用的过程中有很多方法是很容易被混淆的,今天来总结一下js中数组和字符串的方法. ♦数组(Array)的方法 1.push() 和 po ...

  10. 安全协议系列(四)----SSL与TLS

    当今社会,电子商务大行其道,作为网络安全 infrastructure 之一的 -- SSL/TLS 协议的重要性已不用多说.OpenSSL 则是基于该协议的目前应用最广泛的开源实现,其影响之大,以至 ...