Created by Apple on 15/6/17.
Copyright (c) year 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:@ "phone sharing" icon:nil option:^{//Call completion will go back to the current app and will not go back to the current app before
Nsurl *url = [Nsurl urlwithstring:@ "tel://1008611"];
// [[UIApplication sharedapplication] openURL:url];
//You will be prompted before calling back to the current app private 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:@ "sms Sharing" Icon:nil option:^{
After sending out the text message. Will go to the SMS interface
Nsurl *url = [Nsurl urlwithstring:@ "sms://hahaha"];
[[UIApplication sharedapplication] openurl:url];
Determine if the device can send information
if (![ Mfmessagecomposeviewcontroller Cansendtext]) {
Return
}
Mfmessagecomposeviewcontroller *VC = [Mfmessagecomposeviewcontroller new];
Recipient list
vc.recipients = @[@ "10000", @ "10086"];
Vc.body = @ "Recommend a NB game http://www.nbcoder.com/test";
Vc.subject = @ "Biaoti";
Set up Proxy
Vc.messagecomposedelegate = weakself;
[Weakself PRESENTVIEWCONTROLLER:VC Animated:yes Completion:nil];
}];
Lcitem *item3 = [Lcitemarrow itemwithtitle:@ "mail sharing" Icon:nil option:^{
Determine if a message can be sent
if (![ Mfmailcomposeviewcontroller Cansendmail]) {
Return
}
Mfmailcomposeviewcontroller *VC = [Mfmailcomposeviewcontroller new];
Vc.mailcomposedelegate = weakself;
Set recipient
[VC settorecipients:@[@][email protected]",@"[email protected]"]];
Secret delivery
[VC setbccrecipients:<# (Nsarray *) #>]
Cc
[VC setccrecipients:<# (Nsarray *) #>]
[VC setsubject:@ "collect benefits"];
[VC setmessagebody:@ "Send Beauty" 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---------
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
Call/SMS sharing/email sharing