一、调用系统的电话
//调用系统打电话功能 - (void)callPhoneNumber { NSString *allString = [NSString stringWithFormat:@"tel:10086"]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:allString]]; }
二、调用系统的邮件功能
//调用系统邮箱 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://admin@hzlzh.com"]];
三、调用系统的Safari
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.baidu.com"]];
四、调用系统的短信动能
1、该功能要进行一些相关配置操作
1)添加MessageUI.framework
2)导入头文件
#import <MessageUI/MFMessageComposeViewController.h>
3)遵守协议
<MFMessageComposeViewControllerDelegate>
//调用发短信方法 [self sendSMS:@"101" recipientList:@[@"10010"]]; //内容,收件人列表 - (void)sendSMS:(NSString *)bodyOfMessage recipientList:(NSArray *)recipients { MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init]; if([MFMessageComposeViewController canSendText]) { controller.body = bodyOfMessage; controller.recipients = recipients; controller.messageComposeDelegate = self; [self presentViewController:controller animated:YES completion:nil]; } } // 处理发送完的响应结果 - (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result { [self dismissViewControllerAnimated:YES completion:nil]; if (result == MessageComposeResultCancelled) NSLog(@"Message cancelled"); else if (result == MessageComposeResultSent) NSLog(@"Message sent"); else NSLog(@"Message failed"); }
tip:调用系统的这几个功能都需要在真机上测试!