zoukankan      html  css  js  c++  java
  • 系统功能调用

    一、调用系统的电话

    //调用系统打电话功能
    - (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:调用系统的这几个功能都需要在真机上测试!

  • 相关阅读:
    【Web__Cookie】常规使用
    【MVC__ExceptionFilter】全局异常处理
    【 自定义友好错误页 】
    【前端__iframe】web页面框架的使用相关
    【JS__UEditor】富文本编辑器的使用
    简单五子棋,没有电脑AI
    C# 打印倒三角
    C# 抽象类
    递归算法输出数列的前N个数
    case when then else end 累加
  • 原文地址:https://www.cnblogs.com/fengzhihao/p/5230278.html
Copyright © 2011-2022 走看看