与UIActivityViewController共享ALAsset fullResolutionImage

与UIActivityViewController共享ALAsset fullResolutionImage

问题描述:

似乎无法在电子邮件中嵌入全分辨率素材资源。如果我使用fullScreenImage表示,它会很好用。我想应该有一些图像大小的限制,但我找不到任何有关它的信息。我在iPhone 4S上,全分辨率图像是2448 x 3264像素。与UIActivityViewController共享ALAsset fullResolutionImage

代码:

ALAssetRepresentation *assetRepresentation = [_asset defaultRepresentation]; 
CGImageRef imageRef = [assetRepresentation fullResolutionImage]; 
UIImage *img = [UIImage imageWithCGImage:imageRef scale:[assetRepresentation scale] orientation:[assetRepresentation orientation]]; 

UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:@[img] applicationActivities:nil]; 
[self presentViewController:activityController animated:YES completion:nil]; 

谢谢!

解决方法如下:不要将fullResolutionImage添加到要共享的数据数组中,而是添加实际资产本身。

UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:@[_asset] applicationActivities:nil]; 
[self presentViewController:activityController animated:YES completion:nil]; 

其中_asset是图像的ALAsset实例。

+0

非常感谢!你让我今天一整天都感觉很好! :) – Nuthinking