Skip to content
This repository has been archived by the owner on Jul 27, 2020. It is now read-only.

Commit

Permalink
fixed bug in sharing with both title and image
Browse files Browse the repository at this point in the history
  • Loading branch information
iDay committed Dec 5, 2013
1 parent 5b01874 commit 7b25683
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions WeixinActivity/WeixinActivity.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,30 @@ - (void)prepareWithActivityItems:(NSArray *)activityItems
}
}

- (void)setThumbImage:(SendMessageToWXReq *)req
{
if (image) {
CGFloat width = 100.0f;
CGFloat height = image.size.height * 100.0f / image.size.width;
UIGraphicsBeginImageContext(CGSizeMake(width, height));
[image drawInRect:CGRectMake(0, 0, width, height)];
UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[req.message setThumbImage:scaledImage];
}
}

- (void)performActivity
{
SendMessageToWXReq *req = [[SendMessageToWXReq alloc] init];
req.scene = scene;
// req.bText = NO;
req.message = WXMediaMessage.message;
req.message.title = title;
[self setThumbImage:req];
if (url) {
WXWebpageObject *webObject = WXWebpageObject.object;
webObject.webpageUrl = [url absoluteString];
if (image) {
req.message.thumbData = UIImageJPEGRepresentation(image, 0.6f);
}
req.message.mediaObject = webObject;
} else if (image) {
WXImageObject *imageObject = WXImageObject.object;
Expand Down

0 comments on commit 7b25683

Please sign in to comment.