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

  • 相关阅读:
    win8应用的编码UI测试
    什么是Peer Review
    Android开发环境的搭建
    运用int.parse()判断闰年代码实现
    等价类划分方法的应用之EditBox(二)
    等价类划分方法的应用之EditBox
    集成测试
    数据可视化简介
    关于processing
    白盒测试VS黑盒测试
  • 原文地址:https://www.cnblogs.com/fengzhihao/p/5230278.html
Copyright © 2011-2022 走看看