iphone-调系统电话,短信、发邮件等功能(自动返回程序)
来源:互联网 发布:c语言产生1-100随机数 编辑:程序博客网 时间:2024/06/05 10:47
方法一:
//在iPhone中,可以直接用UIApp打开URL地址。如下所示:[ UIApp openURL: [ NSURL URLWithString:@"http://www.apple.com" ] ];//或者:[ UIApp openURL: [ NSURL URLWithString:@"mailto:apple@mac.com?Subject=hello" ] ];//与此同时,iPhone还包含一些其他除了http://或者mailto:之外的URL:sms:// 可以调用短信程序tel:// 可以拨打电话itms:// 可以打开MobileStore.appaudio-player-event:// 可以打开iPodaudio-player-event://?uicmd=show-purchased-playlist 可以打开iPod播放列表video-player-event:// 可以打开iPod中的视频
以简单使用系统功能,但使用系统功能后无法自动回到程序原界面,
电话,短信,邮件功能可用以下方法
方法二:
电话
NSString *mobileNumber = [NSString stringWithFormat:@"telprompt://%@", PhoneNumber]; NSLog(@"call phone %@;", mobileNumber); [[UIApplication sharedApplication] openURL:[NSURL URLWithString:mobileNumber]];
邮件 使用MFMailComposeViewController
引入头文件 #import <MessageUI/MFMailComposeViewController.h>
//发邮箱 Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));if (mailClass != nil){// We must always check whether the current device is configured for sending emailsif ([mailClass canSendMail]){[self displayMailComposerSheet:MailNumber];}else{[self launchMailAppOnDevice];}}else{[self launchMailAppOnDevice];}
//-----------------------------------(void)displayMailComposerSheet:(NSString *)strMail{ NSLog(@"displayMailComposerSheet"); if (_Emailpicker == nil) { _Emailpicker = [[MFMailComposeViewController alloc] init]; _Emailpicker.mailComposeDelegate = self; [_Emailpicker setSubject:@""]; }// Set up recipientsNSArray *toRecipients = [NSArray arrayWithObject:strMail]; [_Emailpicker setToRecipients:toRecipients];[_Emailpicker setMessageBody:@"" isHTML:NO];[self presentModalViewController:Emailpicker animated:YES]; }-(void)launchMailAppOnDevice{ MyLog(@"launchMailAppOnDevice");}// 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 {[controller dismissModalViewControllerAnimated:NO];//邮件视图下拉消失}短信:(使用MFMessageComposeViewController )Class messageClass = (NSClassFromString(@"MFMessageComposeViewController")); NSLog(@"can send SMS [%d]", [messageClass canSendText]); if (messageClass != nil) { if ([messageClass canSendText]) { [self displayMessageComposerSheet:MsmNumber]; } else { [self launchMessageAppOnDevice];//设备没有短信功能 } } else { [self launchMessageAppOnDevice];//iOS版本过低,iOS4.0以上才支持程序内发送短信 }
-(void)displayMessageComposerSheet:(NSString *)strMail{ MyLog(@"displayMessageComposerSheet"); MFMessageComposeViewController *messagePicker = [[MFMessageComposeViewController alloc] init]; messagePicker.messageComposeDelegate = self; messagePicker.body = @""; [self presentModalViewController:messagePicker animated:YES];//[[[[UIApplication sharedApplication] keyWindow] rootViewController] presentModalViewController:_Emailpicker animated:YES]; [messagePicker release];}-(void)launchMessageAppOnDevice{ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"此设备不支持发送短信或系统版本过低" delegate:nil cancelButtonTitle:@"确定 " otherButtonTitles:nil, nil]; [alert show]; [alert release];}- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result{ [controller dismissModalViewControllerAnimated:NO];}0 0
- iphone-调系统电话,短信、发邮件等功能(自动返回程序)
- iphone-调系统电话,短信等功能(自动返回程序)
- 在iphone程序中调用 电话,短信,网页,邮件功能
- 在iphone程序中调用 电话,短信,网页,邮件功能
- ionic 实现拨打电话、发短信、发邮件功能
- iOS开发:APP拨打电话、发短信、发邮件功能
- iPhone调用发短信,电话,邮件的方法
- 仿照iPhone实现电话,邮件,短信,博客功能
- web页面实现拨打电话,发短信等功能
- iOS程序中调用系统自带应用(短信,邮件,浏览器,地图,appstore,拨打电话等)
- iPhone开发之调用系统地图、邮件、电话、短信、浏览器
- APP拨打电话&发短信&发邮件
- iPhone调用短信、邮件等系统功能时界面显示中文的方法
- 自动调用系统发邮件功能
- iphone调用系统电话、浏览器、地图、邮件等
- iphone调用系统电话、浏览器、地图、邮件等
- iphone调用系统电话、浏览器、地图、邮件等
- iphone调用系统电话、浏览器、地图、邮件等
- win7 64位 orcale11g pl/sql
- 合作开发合同的范本
- 原来dreamveaver cs4完整版是不需要安装jquery api的
- Dual paraboloid shadow mapping
- Android ListView最佳处理方式,ListView拖动防重复数据显示,单击响应子控件
- iphone-调系统电话,短信、发邮件等功能(自动返回程序)
- java中substring的用法
- SD卡的读写和FatFS文件系统
- Leftmost Digit
- 判断当前网络类型
- TestNG整理
- centos6.3-64位搭建LAMP环境之安装apache2.4.7
- One Sample Camera Motion Blur
- 宏定义在.h和.cpp中的差别