1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//
// 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