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
@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"];
// 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];
}];
//打电话之前会有提示 回到当前应用 私有的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];
}
}
- (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