官方代码

发短息和邮件添加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. Lyft押重注于苹果编程语言Swift

    Lyft押重注于苹果编程语言Swift 1年后获得丰厚回报BI中文站 8月22日报道 一年多以前,打车应用Lyft做出重大决定,决心押重注于苹果开发的编程语言Swift,用这种编程语言重写其所有iPh ...

  2. Git 分支

    Git 保存的不是文件的变化或者差异,而是一系列不同时刻的文件快照,某一次的提交指向这处时刻的文件快照,看起来就像每次提交都保存了当时的文件,连续的提交形成一条长链 分支 指向某一个特定的提交,不同的 ...

  3. DevExpress--navBarControl控件

    一.在工具箱Navigation&Layout下找到控件navBarControl,拽到相应的位置. 二.点击控件右上角的小三角,对其进行设计:如下图 点Add group可迅速添加组列表,点 ...

  4. Python - twisted web 入门学习之一

    原文地址:http://zhouzhk.iteye.com/blog/765884 python的twisted框架中带了一个web server: twisted web.现在看看怎么用. 一)准备 ...

  5. MySQL主主复制

    MySQL5. 主主复制 环境如下: CentOS6.4_64 MySQL5. master1:192.168.10.11 master2:192.168.10.12 1.1 配置 master1 a ...

  6. windows10 声音图标总是被禁用,检测显示:扬声器,耳机或者耳机已拔出

    参考来源:http://jingyan.baidu.com/article/90bc8fc85de19df652640c7f.html 控制面板/应用和声音/Realtek高清晰音频管理器 点击右上角 ...

  7. 讨论SEO中是锚文本有效,还是纯文本有效呢?

    现在很多SEO好友不断在讨论,在SEO优化中,到底是锚文本有效,还是纯文本有效呢? 在这里给大家举一下列子:如“张家口人才网”这样的就叫做锚文本,意思是在原有的文本中加上超级链接,指向到优化的网页上面 ...

  8. golang调用EXE

    我是win7+go1.7+liteide,调用calc.exe package main import ( "os/exec" ) func main() { datapath : ...

  9. C/C++中的NULL讨论和总结

    代码如下 #include <stdio.h> int main(){ int *p; p = NULL; printf("p=0x%x\n",p); typedef ...

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

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