@@ -286,7 +286,13 @@ - (void)p_doShareToSnsName:(NSString *)snsName{
286
286
}
287
287
NSString *shareContent = [NSString stringWithFormat: @" %@%@%@ " , shareTitle, shareText, shareTail];
288
288
[self showStatusBarQueryStr: @" 正在分享到新浪微博" ];
289
- [[UMSocialDataService defaultDataService ] postSNSWithTypes: @[UMShareToSina] content: shareContent image: nil location: nil urlResource: nil presentedController: [BaseViewController presentingVC ] completion: ^(UMSocialResponseEntity *response) {
289
+
290
+ UMSocialUrlResource *urlResource = nil ;
291
+ NSString *imageUrl = [self p_imageUrl ];
292
+ if (imageUrl.length > 0 ) {
293
+ urlResource = [[UMSocialUrlResource alloc ] initWithSnsResourceType: UMSocialUrlResourceTypeImage url: imageUrl];
294
+ }
295
+ [[UMSocialDataService defaultDataService ] postSNSWithTypes: @[UMShareToSina] content: shareContent image: nil location: nil urlResource: urlResource presentedController: [BaseViewController presentingVC ] completion: ^(UMSocialResponseEntity *response) {
290
296
if (response.responseCode == UMSResponseCodeSuccess) {
291
297
[self showStatusBarSuccessStr: @" 分享成功" ];
292
298
}else {
@@ -366,6 +372,19 @@ - (NSString *)p_shareText{
366
372
}
367
373
return text;
368
374
}
375
+ - (NSString *)p_imageUrl {
376
+ __block NSString *imageUrl = nil ;
377
+ if ([_objToShare respondsToSelector: NSSelectorFromString (@" htmlMedia" )]) {
378
+ HtmlMedia *htmlMedia = [_objToShare valueForKey: @" htmlMedia" ];
379
+ [htmlMedia.imageItems enumerateObjectsUsingBlock: ^(HtmlMediaItem *obj, NSUInteger idx, BOOL *stop) {
380
+ if (obj.type == HtmlMediaItemType_Image) {
381
+ imageUrl = obj.src ;
382
+ *stop = YES ;
383
+ }
384
+ }];
385
+ }
386
+ return imageUrl;
387
+ }
369
388
#pragma mark TranspondMessage
370
389
371
390
- (void )willTranspondMessage : (PrivateMessage *)message {
@@ -398,7 +417,14 @@ -(void)didSelectSocialPlatform:(NSString *)platformName withSocialData:(UMSocial
398
417
// 设置分享内容,和回调对象
399
418
{
400
419
socialData.shareText = [self p_shareText ];
401
- socialData.shareImage = [UIImage imageNamed: @" logo_about" ];
420
+ NSString *imageUrl = [self p_imageUrl ];
421
+ if (imageUrl.length > 0 ) {
422
+ socialData.urlResource = [[UMSocialUrlResource alloc ] initWithSnsResourceType: UMSocialUrlResourceTypeImage url: imageUrl];
423
+ socialData.shareImage = nil ;
424
+ }else {
425
+ socialData.urlResource = nil ;
426
+ socialData.shareImage = [UIImage imageNamed: @" logo_about" ];
427
+ }
402
428
}
403
429
if ([platformName isEqualToString: @" wxsession" ]) {
404
430
UMSocialWechatSessionData *wechatSessionData = [UMSocialWechatSessionData new ];
0 commit comments