• supersr--打电话/短信分享/邮件分享


    //  Created by apple on 15/6/17.

    //  Copyright (c) 2015 Super All rights reserved.

    //

     

    #import "LCShareController.h"

    #import <MessageUI/MessageUI.h>
    @interface LCShareController () <MFMessageComposeViewControllerDelegate,MFMailComposeViewControllerDelegate>
    @property (nonatomic, strong) UIWebView *webView;
    @end

    @implementation LCShareController

    - (void)dealloc{
        NSLog(@"dealloc");
    }


    - (UIWebView *)webView{
        if (_webView == nil) {
            _webView = [UIWebView new];
           
        }
        return _webView;
    }



    - (void)setData{
       
       
    //    __weak LCShareController *weakSelf = self;
       
        __weak typeof(self) weakSelf = self;
       
        LCItem *item1 = [LCItemArrow itemWithTitle:@"电话分享" icon:nil option:^{
            //通话完成会回到当前应用, 以前的时候不会回到当前应用
    //        NSURL *url = [NSURL URLWithString:@"tel://1008611"];
    //        [[UIApplication sharedApplication] openURL:url];
           
           
            //打电话之前会有提示  回到当前应用  私有的api
    //        NSURL *url = [NSURL URLWithString:@"telprompt://10086"];
    //        [[UIApplication sharedApplication] openURL:url];
           
            NSURL *url = [NSURL URLWithString:@"tel://10086"];
            NSURLRequest *request = [NSURLRequest requestWithURL:url];
            [weakSelf.webView loadRequest:request];
           
        }];
       
        LCItem *item2 = [LCItemArrow itemWithTitle:@"短信分享" icon:nil option:^{
           
            //发完短信之后。会到短信界面
    //        NSURL *url = [NSURL URLWithString:@"sms://哈哈哈"];
    //        [[UIApplication sharedApplication] openURL:url];
           
           
            //判断设备是否能发送信息
            if (![MFMessageComposeViewController canSendText]) {
                return;
            }
           
            MFMessageComposeViewController *vc = [MFMessageComposeViewController new];
            //收件人列表
            vc.recipients = @[@"10000",@"10086"];
            vc.body = @"推荐一个nb的游戏 http://www.nbcoder.com/test";
            vc.subject = @"biaoti";
            //设置代理
            vc.messageComposeDelegate = weakSelf;
           
            [weakSelf presentViewController:vc animated:YES completion:nil];
           
        }];
       
        LCItem *item3 = [LCItemArrow itemWithTitle:@"邮件分享" icon:nil option:^{
           
            //判断是否能发送邮件
            if (![MFMailComposeViewController canSendMail]) {
                return;
            }
           
            MFMailComposeViewController *vc = [MFMailComposeViewController new];
           
            vc.mailComposeDelegate = weakSelf;
            //设置收件人
            [vc setToRecipients:@[@"super1250@126.cn",@"2222@126.cn"]];
            //密送
    //        [vc setBccRecipients:<#(NSArray *)#>]
            //抄送
    //        [vc setCcRecipients:<#(NSArray *)#>]
           
            [vc setSubject:@"收福利了"];
            [vc setMessageBody:@"送美女" isHTML:NO];
           
            //
            UIImage *img = [UIImage imageNamed:@"aa"];
            NSData *data = UIImagePNGRepresentation(img);
           
            [vc addAttachmentData:data mimeType:@"image/png" fileName:@"cls.png"];
           
           
           
            [weakSelf presentViewController:vc animated:YES completion:nil];
           
        }];
       
        //controller(self) --> self.groups -->  group  -->  item   --> option  --> self
       
        LCGroup *group = [LCGroup groupWithItems:@[item1,item2,item3]];
        self.groups = @[group];
    }

    - (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error{
        [controller  dismissViewControllerAnimated:YES completion:nil];

    }


    - (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result{
        [controller  dismissViewControllerAnimated:YES completion:nil];
    }

    @end
  • 相关阅读:
    mysql命令大全(转发)
    算法大神学习之路
    MYSQL之explain的作用与相关知识
    FastDFS(分布式存储系统)+nginx web 服务器
    获取用户浏览历史记录(django_redis)
    用户登陆装饰器和页面跳转(包含mixin的使用)
    .NET 方法回调
    asp.net viewstate 数据过大 导致错误
    asp.net viewstate 数据大导致错误
    软件测试 Record
  • 原文地址:https://www.cnblogs.com/supersr/p/4830396.html
Copyright © 2020-2023  润新知