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张图像,甚至是原始高清尺寸的系统照片断言.
那么,我该如何解决这个问题呢?
解决方法
根据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