// // KWMShareVC.m // iCemarose // // Created by HouWeiBin on 2017/2/27. // Copyright © 2017年 kollway. All rights reserved. // #import "KWMShareVC.h" #import "KWMWeChatUtil.h" @interface KWMShareVC () @end @implementation KWMShareVC - (void)viewDidLoad { [super viewDidLoad]; self.view.userInteractionEnabled = YES; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClickCancel:)]; [self.view addGestureRecognizer:tap]; // Do any additional setup after loading the view. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } +(NSString *)kwmTag{ return @"KWMShareVC"; } -(void)onShareToCircle:(id)sender{ if(self.shareUrl){ //设置图片 NSURL *imageURL = [NSURL URLWithString:self.imageUrl]; UIImage *image = [UIImage imageWithData:[[NSData alloc] initWithContentsOfURL:imageURL]]; [KWMWeChatUtil shareToCircleWithTitle:self.productName message:@"这个衣服很不错,你也来看看吧" image:image urlString:self.shareUrl sender:self]; } } -(void)onShareToFriend:(id)sender{ if(self.shareUrl){ //设置图片 NSURL *imageURL = [NSURL URLWithString:self.imageUrl]; UIImage *image = [UIImage imageWithData:[[NSData alloc] initWithContentsOfURL:imageURL]]; [KWMWeChatUtil shareToFriendWithTitle:self.productName message:@"这个衣服很不错,你也来看看吧" image:image urlString:self.shareUrl sender:self]; } } -(void)onShareToMessage:(id)sender{ if(self.shareUrl){ if([MFMessageComposeViewController canSendText]){ [[UINavigationBar appearance] setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault]; UIColor *baseColor = [UIColor darkGrayColor]; [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: baseColor,NSForegroundColorAttributeName: baseColor,NSFontAttributeName: [UIFont systemFontOfSize:18.0f]}]; MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init]; //NSArray *phones = [[NSArray alloc] initWithObjects:phone.phone, nil]; controller.body = [NSString stringWithFormat:@"这个衣服很不错,你也来看看吧<%@>", self.shareUrl]; //[controller setRecipients:phones]; controller.messageComposeDelegate = self; [self presentViewController:controller animated:YES completion:nil]; } } } // 处理发送完的响应结果 - (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result{ [self dismissViewControllerAnimated:YES completion:nil]; } -(void)onClickCancel:(id)sender{ [self dismissViewControllerAnimated:YES completion:^{ }]; } @end