打开相机、相册

打开相机代码
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
        UIImagePickerController *picker = [[UIImagePickerController alloc]init];
        picker.delegate = self;
        picker.allowsEditing = YES;
        picker.sourceType = UIImagePickerControllerSourceTypeCamera;
        [self presentViewController:picker animated:YES completion:^{}];
    }
打开相册代码
    UIImagePickerController *picker = [[UIImagePickerController alloc]init];
    picker.delegate = self;
    picker.allowsEditing = YES;
    [self presentViewController:picker animated:YES completion:^{}];

选择照片代码
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
    
    UIImageView *imageview = (UIImageView*)[self.view viewWithTag:100];
    imageview.image = [info objectForKey:UIImagePickerControllerOriginalImage];
    [picker dismissViewControllerAnimated:YES completion:^{}];
    NSLog(@"%@",info);
}

代理方法

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
    [self dismissViewControllerAnimated:YES completion:^{}];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
    
    UIImageView *imageview = (UIImageView*)[self.view viewWithTag:100];
<div class="line number67 index66 alt2"><code class="cpp spaces">    </code><code class="cpp comments">// UIImagePickerControllerOriginalImage 原始图片</code></div><div class="line number68 index67 alt1"><code class="cpp spaces">    </code><code class="cpp comments">// UIImagePickerControllerEditedImage 编辑后图片</code></div>
    imageview.image = [info objectForKey:UIImagePickerControllerOriginalImage];
    [picker dismissViewControllerAnimated:YES completion:^{}];
    NSLog(@"%@",info);
}

打开短信代码 首先要导入库

//    MFMessageComposeViewController *mf = [[MFMessageComposeViewController alloc]init];
//    if ([MFMessageComposeViewController canSendText]) {
//        mf.body = @"中午我回去不";
//        mf.recipients = [NSArray arrayWithObjects:@"15038207937", nil];
//        mf.messageComposeDelegate = self;
//        [self presentViewController:mf animated:YES completion:^{}];
//    }

必要的代理方法

- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result{
    
    [self dismissViewControllerAnimated:YES completion:^{}];
    NSLog(@"%d",result);
}
打电话的方法代码

方法一:

    UIWebView *callwebview = [[UIWebView alloc]init];
    NSString *phone = @"********";
    NSString *telurl = [NSString stringWithFormat:@"tel:%@",phone];
    NSURL *telURL = [NSURL URLWithString:telurl];
    [callwebview loadRequest:[NSURLRequest requestWithURL:telURL]];
    [self.view addSubview:callwebview];
方法二:
 NSString *phone = @"*********";
     NSString *telUrl = [NSString stringWithFormat:@"telprompt:%@",phone];
    [[UIApplication sharedApplication]openURL:[NSURL URLWithString:telUrl]];
发送邮件代码
MFMailComposeViewController *mail = [[MFMailComposeViewController alloc]init];
    mail.mailComposeDelegate = self;
    [mail setMessageBody:@"jintiantianqibucuo" isHTML:YES];//邮箱内容
    [mail setToRecipients:[NSArray arrayWithObjects:@"875744894@qq.com", nil]];//发送对象
    [mail setCcRecipients:[NSArray arrayWithObjects:@"875744894@qq.com", nil]];//抄送人
    [mail setBccRecipients:[NSArray arrayWithObjects:@"875744894@qq.com", nil]];//密送对象
    [mail setSubject:@"wo"];//主题
    [self presentViewController:mail animated:YES completion:^{}];






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值