ios – UIActivityViewController将图像分享到微信无法正常工作

ios – UIActivityViewController将图像分享到微信无法正常工作,第1张

概述当我使用Apple的UIActivityViewController与WeChat(weixin)共享一些图像时.我发现有时它不起作用.大多数情况下,当我只选择1~3张图像时效果很好,但如果我共享9张图片(微信允许的最大数量),它肯定会失败,控制台会打印出来 2016-04-01 16:14:34.258 EverPhoto[5567:1981394] plugin com.tencent.xin 当我使用Apple的UIActivityVIEwController与WeChat(weixin)共享一些图像时.我发现有时它不起作用.大多数情况下,当我只选择1~3张图像时效果很好,但如果我共享9张图片(微信允许的最大数量),它肯定会失败,控制台会打印出来

2016-04-01 16:14:34.258 EverPhoto[5567:1981394] plugin
com.tencent.xin.sharetimeline interrupted 2016-04-01 16:14:34.258
EverPhoto[5567:1981394] plugin com.tencent.xin.sharetimeline
invalIDated

这是代码:

__weak typeof(self) __weakSelf = self;self.activityVIEwController = [[UIActivityVIEwController alloc] initWithActivityItems:self.shareItems applicationActivitIEs:nil];self.activityVIEwController.excludedActivityTypes = @[UIActivityTypePostToFacebook,UIActivityTypePostToTwitter,UIActivityTypePostToVimeo,UIActivityTypePostToTencentWeibo,UIActivityTypePrint,UIActivityTypecopytopasteboard,UIActivityTypeAssignToContact,UIActivityTypeSavetoCameraRoll,UIActivityTypeAddToReadingList,UIActivityTypePostToFlickr,];self.activityVIEwController.completionWithItemsHandler = ^(Nsstring * __nullable activityType,BOol completed,NSArray * __nullable returnedItems,NSError * __nullable activityError){    DLog(@"shareCompleted : %@",completed ? @"YES" : @"NO")    __weakSelf.shareItems = nil;    __weakSelf.activityVIEwController = nil;};[self.containerVc presentVIEwController:self.activityVIEwController animated:YES completion:nil];

ShareItems是实现协议UIActivityItemSource的自定义对象.

附:我尝试了APP Google Photo,发现它在共享功能方面做得很好.它可以使用UIActivityVIEwController与WeChat共享9张图像,甚至是原始高清尺寸的系统照片断言.
那么,我该如何解决这个问题呢?

解决方法 由于App Extension的内存限制,微信的共享扩展已终止.
根据Apple的 App Extension Programming Guide:优化效率和性能

Memory limits for running app extensions are significantly lower than the memory limits imposed on a foreground app. On both platforms,the system may aggressively terminate extensions because users want to return to their main goal in the host app. Some extensions may have lower memory limits than others: For example,Widgets must be especially efficIEnt because users are likely to have several Widgets open at the same time.

1.我创建了9个非常小的图像,并与微信成功分享:

- (UIImage *)imageWithcolor:(UIcolor *)color{  CGRect rect = CGRectMake(0,1,1);  UIGraphicsBeginImageContext(rect.size);  CGContextRef context = UIGraphicsGetCurrentContext();  CGContextSetFillcolorWithcolor(context,[color CGcolor]);  CGContextFillRect(context,rect);  UIImage *image = UIGraphicsGetimageFromCurrentimageContext();  UIGraphicsEndImageContext();  return image;}

2.在与微信分享之前,您可以缩小图像,这里是Scale methods

总结

以上是内存溢出为你收集整理的ios – UIActivityViewController将图像分享到微信无法正常工作全部内容,希望文章能够帮你解决ios – UIActivityViewController将图像分享到微信无法正常工作所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1099427.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存