调用电话,短信,打开网址

email

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://admin@hzlzh.com"]];

phone

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8008808888"]];

safari

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.hzlzh.com"]];

sms

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://800888"]];

调用phone可以传递号码,调用SMS 只能设定号码,不能初始化SMS内容。

编辑sms内容

#import <MessageUI/MFMessageComposeViewController.h>
- (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 presentModalViewController:controller animated:YES];
    }   
}

#pragma mark - MFMessageComposeViewControllerDelegate

- (void)messageComposeViewController:(MFMessageComposeViewController *)controller 
    didFinishWithResult:(MessageComposeResult)result {
     [self dismissModalViewControllerAnimated:YES];

     if (result == MessageComposeResultCancelled)
        NSLog(@"Message cancelled")
     else if (result == MessageComposeResultSent)
        NSLog(@"Message sent")  
     else 
        NSLog(@"Message failed")  
}

发送邮件

#import <MessageUI/MFMailComposeViewController.h>

- (void)sendMail:(NSString *)subject content:(NSString *)content {
    MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];

    if ([MFMailComposeViewController canSendMail]) {
        [controller setSubject:subject];
        [controller setMessageBody:content isHTML:NO];
        controller.mailComposeDelegate = self;
        [self presentModalViewController:controller animated:YES];
    }    
}

#pragma mark - MFMailComposeViewControllerDelegate

- (void)mailComposeController:(MFMailComposeViewController *)controller 
    didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
    [self dismissModalViewControllerAnimated:YES];

    if (result == MessageComposeResultCancelled)
        NSLog(@"Message cancelled");
    else if (result == MessageComposeResultSent)
        NSLog(@"Message sent"); 
    else 
        NSLog(@"Message failed");  
}
```
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 教父这部电影看了几遍,之前在大学的时候因为情节沉闷,往往看不下去。后来走向工作岗位慢慢地看下去了。 发现越看越有感...
    在事上磨阅读 302评论 0 0
  • 七一,下半年的第一天,香港回归二十周年,建党日,那就来简单说道说道香港吧。 从儿时开始,港澳对于我们来说与美帝无异...
    丹竹小馆阅读 184评论 0 0
  • 今天是金老爷子九十二岁生辰,经外子提醒,才想起来他老人家还是我们的红媒。 多年前,初识外子 ,曾论及金庸江湖里的诸...
    刺猬的树洞阅读 357评论 2 3

友情链接更多精彩内容