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

  • 相关阅读:
    QT开发之旅一DS7400主机调试工具
    读《程序员,你伤不起》杂感(附带分享两个项目源码)
    这些年过上幸福生活的程序员(中篇)
    这些年过上幸福生活的程序员(上篇)
    如果第三方数据表与系统数据库里的表名格式不一致的解决方案
    数据库设计原则
    MYSQL密码设置
    关于phpmyadmin #1045无法登陆服务器的问题
    TP快捷函数
    跨控制器调用
  • 原文地址:https://www.cnblogs.com/fengzhihao/p/5230278.html
Copyright © 2011-2022 走看看