官方代码

发短息和邮件添加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. (转)Spring中@Async用法总结

     原文:http://blog.csdn.net/blueheart20/article/details/44648667 引言: 在Java应用中,绝大多数情况下都是通过同步的方式来实现交互处理的: ...

  2. asp.net MVC之 自定义过滤器(Filter) - shuaixf

    一.系统过滤器使用说明 1.OutputCache过滤器 OutputCache过滤器用于缓存你查询结果,这样可以提高用户体验,也可以减少查询次数.它有以下属性: Duration :缓存的时间, 以 ...

  3. wxPython入门练习代码 一

    Bare.py: #1.导入必须的wxPython包 import wx #2.子类化wx应用程序类 class App(wx.App): #3.定义应用程序初始化方法 def OnInit(self ...

  4. Bootstrap <基础二十六>进度条

    Bootstrap 进度条.在本教程中,你将看到如何使用 Bootstrap 创建加载.重定向或动作状态的进度条. Bootstrap 进度条使用 CSS3 过渡和动画来获得该效果.Internet ...

  5. Android中的自定义视图控件

    简介 当现有控件不能满足需求时,就需要自定义控件. 自定义控件属性 自定义控件首先要继承自View,重写两个构造函数. 第一个是代码中使用的: public MyRect(Context contex ...

  6. 修改加粗cmd和powershell命令行的中文字体

    powershell 传教士 原创文章 2016-06-20 允许转载,但必须保留名字和出处,否则追究法律责任 ---[前言]--- 1 环境: win10 10586 powershell 5.0 ...

  7. 《我是一只IT小小鸟》读后感

    过了半个学期的大学生活,说实话,我是迷茫的,因为我还没有足够的了解IT这门课程,也不知道怎么学好这门课程. 直到老师推荐我们读一本书<我是一只it小小鸟>,起初,我并不认为它是一本多么好的 ...

  8. 解决maven创建web项目卡死在generator插件(转)

    如下图所示:在Properties中添加一个参数archetypeCatalog=internal,不加这个参数,在maven生成骨架的时候将会非常慢,有时候会直接卡住. 理由 archetypeCa ...

  9. js②

    操作符 ECMA-262描述了一组用于操作数据值的操作符,包括算术操作符(如加号和减号).位操作符.关系操作符和相等操作符. 一元操作符 递增和递减操作符(++ --) 一元加和减操作符 对非数值应用 ...

  10. Integer Break(Difficulty: Easy)

    题目: Given a positive integer n, break it into the sum of at least two positive integers and maximize ...