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

  • 相关阅读:
    js设置、修改、获取、删除 cookie
    mysql排序让空值NULL排在数字后边
    javascript的函数作用域及声明提前
    修改mysql的密码
    解决thinkphp设置session周期无效的问题
    filter_var() 验证邮箱、ip、url的格式 php
    将中文字符串分割为数组 解决str_split中文乱码php
    生成多个不重复的随机数字php
    javascript控制input只允许输入数字
    推荐开发工具系列之--Clover(文件浏览器)
  • 原文地址:https://www.cnblogs.com/fengzhihao/p/5230278.html
Copyright © 2011-2022 走看看