作者:林x强 | 来源:互联网 | 2023-05-25 12:17
我正在创建一个应用程序,我想拍摄最近的照片并使用UI活动视图控制器进行分享.出于某种原因,当我尝试分享照片时,我收到错误
ImageIO:PNG zlib错误
这是相关的代码:
let imgManager = PHImageManager.defaultManager()
var fetchOptiOns= PHFetchOptions()
let screenSize: CGSize = UIScreen.mainScreen().bounds.size
let targetSize = CGSizeMake(screenSize.width, screenSize.height)
var imagesArray: NSMutableArray = []
fetchOptions.sortDescriptors = [NSSortDescriptor(key:"creationDate", ascending: true)]
if let fetchResult = PHAsset.fetchAssetsWithMediaType(PHAssetMediaType.Image, options: fetchOptions) {
imgManager.requestImageForAsset(fetchResult.lastObject as PHAsset, targetSize: targetSize, contentMode: PHImageContentMode.AspectFill, options: nil, resultHandler: { (image, _) in
imagesArray.addObject(image)
})
}
let activityViewCOntroller= UIActivityViewController(
activityItems: imagesArray,//[textField.text as NSString],
applicationActivities: nil)
presentViewController(activityViewController, animated: true, completion: nil)
我不知道发生了什么以及错误来自哪里
1> yoshitech..:
我在iOS8应用程序上共享图像时遇到了同样的错误.我通过像这样同步获取图像来解决它.
PHImageRequestOptions *optiOns= [[PHImageRequestOptions alloc]init];
options.synchrOnous= YES;
希望这可以帮助.