iOS 调用彩信 截屏图片 发送彩信图片

- (void)SendMMS{
    NSString * documentsDirectoryPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    [self saveImage:[self convertViewToImage:self.bgView] withFileName:@"rainy" ofType:@"png" inDirectory:documentsDirectoryPath];
   if ([MFMessageComposeViewController canSendAttachments]) {
          MFMessageComposeViewController * messageVC = [[MFMessageComposeViewController alloc]init];
          
          //手机号
//          messageVC.recipients = @[@"136"];
          //发送的内容
          messageVC.body = @"发送内容";
          NSString * documentsDirectoryPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
          NSString * path = [documentsDirectoryPath stringByAppendingPathComponent:@"rainy.png"];
          if ([messageVC addAttachmentURL:[NSURL fileURLWithPath:path] withAlternateFilename:nil])
          {
              NSLog(@"添加成功");
          }else{
              NSLog(@"失败");
          }
          messageVC.messageComposeDelegate = self;
          /** 取消按钮的颜色(附带,可不写) */
          messageVC.navigationBar.tintColor = [UIColor redColor];
          [self presentViewController:messageVC animated:YES completion:nil];
          
      }else{
          NSLog(@"模拟器不支持发送短信");
      }
}

1.首先得先导入#import <MessageUI/MessageUI.h>

2.实现代理MFMessageComposeViewControllerDelegate

3.点击按钮加入上面的代码,这个只是用来发送截图,或者直接存在的图片文本

4.实现代理方法

- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
    /** 发送完信息就回到原程序*/
    [self dismissViewControllerAnimated:YES completion:nil];
    switch (result) {
        case MessageComposeResultSent:
            NSLog(@"发送成功");
            break;
        case MessageComposeResultFailed:
            NSLog(@"发送失败");
            break;
        case MessageComposeResultCancelled:
            NSLog(@"发送取消");
        default:
            break;
    }
}

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值