ios调用系统服务

打开相机代码
[objc]  view plain copy
  1. if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {  
  2.     UIImagePickerController *picker = [[UIImagePickerController alloc]init];  
  3.     picker.delegate = self;  
  4.     picker.allowsEditing = YES;  
  5.     picker.sourceType = UIImagePickerControllerSourceTypeCamera;  
  6.     [self presentViewController:picker animated:YES completion:^{}];  
  7. }  
打开相册代码
[objc]  view plain copy
  1. UIImagePickerController *picker = [[UIImagePickerController alloc]init];  
  2. picker.delegate = self;  
  3. picker.allowsEditing = YES;  
  4. [self presentViewController:picker animated:YES completion:^{}];  

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

代理方法

[objc]  view plain copy
  1. - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{  
  2.     [self dismissViewControllerAnimated:YES completion:^{}];  
  3. }  
  4. - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{  
  5.       
  6.     UIImageView *imageview = (UIImageView*)[self.view viewWithTag:100];  
  7. <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>  
  8.     imageview.image = [info objectForKey:UIImagePickerControllerOriginalImage];  
  9.     [picker dismissViewControllerAnimated:YES completion:^{}];  
  10.     NSLog(@"%@",info);  
  11. }  

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

[objc]  view plain copy
  1. //    MFMessageComposeViewController *mf = [[MFMessageComposeViewController alloc]init];  
  2. //    if ([MFMessageComposeViewController canSendText]) {  
  3. //        mf.body = @"中午我回去不";  
  4. //        mf.recipients = [NSArray arrayWithObjects:@"15038207937", nil];  
  5. //        mf.messageComposeDelegate = self;  
  6. //        [self presentViewController:mf animated:YES completion:^{}];  
  7. //    }  

必要的代理方法

[objc]  view plain copy
  1. - (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result{  
  2.       
  3.     [self dismissViewControllerAnimated:YES completion:^{}];  
  4.     NSLog(@"%d",result);  
  5. }  
打电话的方法代码

方法一:

[objc]  view plain copy
  1. UIWebView *callwebview = [[UIWebView alloc]init];  
  2. NSString *phone = @"********";  
  3. NSString *telurl = [NSString stringWithFormat:@"tel:%@",phone];  
  4. NSURL *telURL = [NSURL URLWithString:telurl];  
  5. [callwebview loadRequest:[NSURLRequest requestWithURL:telURL]];  
  6. [self.view addSubview:callwebview];  
方法二:
[objc]  view plain copy
  1. NSString *phone = @"*********";  
  2.     NSString *telUrl = [NSString stringWithFormat:@"telprompt:%@",phone];  
  3.    [[UIApplication sharedApplication]openURL:[NSURL URLWithString:telUrl]];  
发送邮件代码
[objc]  view plain copy
  1. MFMailComposeViewController *mail = [[MFMailComposeViewController alloc]init];  
  2.     mail.mailComposeDelegate = self;  
  3.     [mail setMessageBody:@"jintiantianqibucuo" isHTML:YES];//邮箱内容  
  4.     [mail setToRecipients:[NSArray arrayWithObjects:@"875744894@qq.com", nil nil]];//发送对象  
  5.     [mail setCcRecipients:[NSArray arrayWithObjects:@"875744894@qq.com", nil nil]];//抄送人  
  6.     [mail setBccRecipients:[NSArray arrayWithObjects:@"875744894@qq.com", nil nil]];//密送对象  
  7.     [mail setSubject:@"wo"];//主题  
  8.     [self presentViewController:mail animated:YES completion:^{}];  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值