Closed maimaiworks closed 8 years ago
@chiunam if you're interested in a fix, I can create a PR. It's pretty easy (I already troubleshot this for some other areas of my own app).
The basic issue is that on iPads in iPhone mode for iOS 9.3+ calls to:
- (PHImageRequestID)requestImageForAsset:(PHAsset *)asset targetSize:(CGSize)targetSize contentMode:(PHImageContentMode)contentMode options:(nullable PHImageRequestOptions *)options resultHandler:(void (^)(UIImage *__nullable result, NSDictionary *__nullable info))resultHandler;
don't work if the dimensions on targetSize
are less than about 500.
Hi @krusek. Really thanks for your help.
i pull the latest commit, failed to resolve the problem. i run the example(demo code) in simulater, the result just same as the issue description. i think the answer in http://stackoverflow.com/questions/28369400/phimagemanager-requestimageforasset-returns-nil-when-creating-thumbnail-for-vide may explain the problem. but i cant find the cause, why this problem happened in iPad only. According to the answer above, i set PHImageRequestOptions.networkAccessAllowed = YES, then the thumbnail image is ok, not return nil any more. still another problem, the photo broswer not work well.
实在是英文很差,设置了 PHImageRequestOptions.networkAccessAllowed = YES 参数后,缩略图能正常显示,图片浏览器有问题。横向照片能正常显示,纵向照片无法显示。我调试了下源码,CTAssetItemViewController.m 中的请求图片逻辑如下 `- (void)requestAssetImage { [self.scrollView setProgress:0];
CGSize targetSize = [self targetImageSize];
PHImageRequestOptions *options = [self imageRequestOptions];
self.imageRequestID =
[self.imageManager ctassetsPickerRequestImageForAsset:self.asset
targetSize:targetSize
contentMode:PHImageContentModeAspectFit
options:options
resultHandler:^(UIImage *image, NSDictionary *info) {
// this image is set for transition animation
self.image = image;
dispatch_async(dispatch_get_main_queue(), ^{
NSError *error = info[PHImageErrorKey];
if (error)
[self showRequestImageError:error title:nil];
else
[self.scrollView bind:self.asset image:image requestInfo:info];
});
}];
}` 我修改了一些地方,targetSize 参数,使用系统提供的表示全图的参数 PHImageManagerMaximumSize ,貌似幸运的解决了问题。并没有完整测试。bug原因也没搞明白。
昨天已经有点头昏了。第一个回复,不能解决问题。让我误以为解决了,因为iPad模拟器有差异。大致测试了四个iPad模拟器,iPad2, iPad Air, iPad Air2, iPad Pro. 正如问题描述人所描述的,出现问题的是 iPad Air, iPad Air2, iPad Pro, 而iPad2是显示正常的。跟那个fix无关。
因为项目需要紧急修复,我找不到原因,只能做个小小修改,让这个问题看起来暂时没这么严重。 CTAssetsPickerController.m 文件中,- (void)initThumbnailRequestOptions 这个方法,将 PHImageRequestOptions.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat; => PHImageRequestOptions.deliveryMode = PHImageRequestOptionsDeliveryModeFastFormat; 牺牲了缩略图的图像质量,但至少能显示了。这个回答主要是纠正上面错误的回答,上面那第二个回复,好像没什么大问题。
Thumbnails does not work. app target :iPhone Test on iPadAir, iPadAir2,iPadPro.