调用拨号
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://号码"]];
调用短信
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://收信号码"]];
如果要填写发送内容
// 导入头文件
#import <MessageUI/MFMessageComposeViewController.h>
// 添加代理
MFMessageComposeViewControllerDelegate
- (void)sendSMS{
MFMessageComposeViewController * mcViewController = [[MFMessageComposeViewController alloc] init];
mcViewController.messageComposeDelegate = self;
if ([MFMessageComposeViewController canSendText]) {
mcViewController.recipients = @[@"18212345678",@"18287654321",@"18243218765"]; // 添加收件人号码,可以添加多个
mcViewController.body = @"这是要发送的短信内容"; // 要发送的内容
[self presentViewController:mcViewController animated:YES completion:nil];
}
}
#pragma mark - MFMessageComposeViewControllerDelegate
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result{
if (result == MessageComposeResultCancelled) {
NSLog(@"短信被取消");
}else if (result == MessageComposeResultSent) {
NSLog(@"短信发送成功");
}else if (result == MessageComposeResultFailed) {
NSLog(@"短信发送失败");
}
}
调用邮件
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://收件人邮箱地址"]];
如果要填写邮件内容
// 导入头文件
#import <MessageUI/MFMailComposeViewController.h>
// 添加代理
MFMailComposeViewControllerDelegate
- (void)sendMail{
MFMailComposeViewController * mcViewController = [[MFMailComposeViewController alloc] init];
mcViewController.mailComposeDelegate = self;
if ([MFMailComposeViewController canSendMail]) {
// 收件人
[mcViewController setToRecipients:@[@"123456789@qq.com"]];
// 抄送
[mcViewController setCcRecipients:@[@"111111111@qq.com",@"222222222@qq.com",@"333333333@qq.com"]];
// 密送
[mcViewController setBccRecipients:@[@"000000000@qq.com"]];
// 主题
[mcViewController setSubject:@"邮件主题"];
// 内容
[mcViewController setMessageBody:@"要发送的邮件内容" isHTML:NO];
[self presentViewController:mcViewController animated:YES completion:nil];
}
}
#pragma mark - MFMailComposeViewControllerDelegate
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error{
if (result == MessageComposeResultCancelled) {
NSLog(@"邮件被取消");
}else if (result == MessageComposeResultSent) {
NSLog(@"邮件发送成功");
}else if (result == MessageComposeResultFailed) {
NSLog(@"邮件发送失败");
}
}
调用Safari
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://网址"]];
调用AppStore
版权声明:出自MajorLMJ技术博客的原创作品 ,转载时必须注明出处及相应链接!