ios 发短息 发邮件 打电话
来源:互联网 发布:网络舆情分析师怎么考 编辑:程序博客网 时间:2024/05/21 06:30
官方代码发短息和邮件添加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. { [self displaySMSComposerSheet]; } else // The device can not send email. { self.feedbackMsg.hidden =NO; self.feedbackMsg.text = @"Device not configured to send SMS."; }- (void)displaySMSComposerSheet { MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init]; picker.messageComposeDelegate =self; picker.navigationBar.tintColor = [UIColor blackColor]; picker.recipients = [NSArray arrayWithObject:@"186888888"]; picker.body =@"Hello from California!"; [self presentViewController:picker animated:YES completion: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 interfaceswitch (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;} [self dismissViewControllerAnimated:YES completion: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. { [self displayMailComposerSheet]; } 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 recipientsNSArray *toRecipients = [NSArray arrayWithObject:@"first@example.com"]; NSArray *ccRecipients = [NSArray arrayWithObjects:@"second@example.com",@"third@example.com", nil]; NSArray *bccRecipients = [NSArray arrayWithObject:@"fourth@example.com"]; [picker setToRecipients:toRecipients];[picker setCcRecipients:ccRecipients];[picker setBccRecipients:bccRecipients];// Attach an image to the emailNSString *path = [[NSBundle mainBundle] pathForResource:@"rainy"ofType:@"jpg"];NSData *myData = [NSData dataWithContentsOfFile:path];[picker addAttachmentData:myData mimeType:@"image/jpeg"fileName:@"rainy"];// Fill out the email body textNSString *emailBody =@"It is raining in sunny California!";[picker setMessageBody:emailBody isHTML:NO];[self presentViewController:picker animated:YES completion: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 interfaceswitch (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;} [self dismissViewControllerAnimated:YES completion:NULL];}打电话 我只写了一种简单的方式 还有其他的添加 AddressBookUI.framework 库#import <AddressBook/AddressBook.h>#import <AddressBook/ABMultiValue.h>#import <AddressBook/ABRecord.h>- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath{ NSString *key = [keyArray objectAtIndex:indexPath.row]; NSArray *array = [tableDataDictionary objectForKey:key]; NSString *phoneNum = [array objectAtIndex:1];//电话号码 NSURL *phoneURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",phoneNum]]; if ( !_phoneCallWebView ) { _phoneCallWebView = [[UIWebView alloc] initWithFrame:CGRectZero]; } [_phoneCallWebView loadRequest:[NSURLRequest requestWithURL:phoneURL]]; }
原文地址:http://blog.csdn.net/lengshengren/article/details/11575511
0 0
- ios 发短息 发邮件 打电话
- iOS 打电话 ,发邮件,发短息
- ios 发短息 发邮件 打电话
- iOS------打电话 ,发信息,发邮件方法
- IOS打电话、发短信、发邮件总结
- iOS------打电话 ,发信息,发邮件方法
- iOS中摇一摇 发短信 打电话 发邮件
- ios 打电话,发邮件,发短信
- iOS 打电话 & 发短信 & 发邮件
- iOS 打电话、发短信、发邮件
- iOS打电话、发短信、发邮件开发
- iOS打电话、发短信、发邮件功能
- iOS开发 打电话 发短信 邮件 评分
- iOS- 如何将应用集成发短信、发邮件、打电话
- iOS之打电话、发短信、发邮件、相机
- iOS打电话、发短信、发邮件功能开发
- iOS- 如何将应用集成发短信、发邮件、打电话
- iOS打电话、发短信、发邮件功能开发
- select()、poll()、epoll()的区别
- Python学习笔记--模块
- Android Building System 分析
- servlet注解的使用
- Fragment 和 FragmentActivity的使用
- ios 发短息 发邮件 打电话
- 安卓开发——onActivityResult中requestcode与resultcode区别
- Pixhawk之姿态解算篇(1)_入门篇(DCM Nomalize)
- 长按删除tableviewCell
- 谈谈我对flexbox的理解
- SilkTest循序渐进3-编程规范
- untiy 2d游戏平面直角坐标系的旋转应用
- 二维码使用之二维码生成
- 上海女性胸部怎样变大