以下所有内容均为个人观点,转载请注明出处<简书--小蜗牛吱呀之悠悠 >,谢谢!
苹果正式发布iOS 14系统后,原先可以显示大图模式的GKPhotoBrowser出现了黑屏,但是在iOS 13系统却是正常的。
GKPhotoBrowser的代码配置如下:
for (int i = 0;i < self.assets.count;i++) {
GKPhoto *photo = [GKPhoto new];
photo.sourceFrame = CGRectMake(WIDTH_SCREEN/2, HEIGHT_SCREEN/2, 1, 1);
[photos addObject:photo];
}
DDPHAsset *asset = self.assets[indexPath.row];
[self.queue addOperationWithBlock:^{
[[PHImageManager defaultManager] requestImageForAsset:asset.asset targetSize: PHImageManagerMaximumSize contentMode:PHImageContentModeAspectFit options:self.options resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) {
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
GKPhoto *photo = photos[indexPath.row];
photo.image = result;
GKPhotoBrowser *browser = [GKPhotoBrowser photoBrowserWithPhotos:photos currentIndex:indexPath.row];
browser.showStyle = GKPhotoBrowserShowStyleZoom;
browser.hideStyle = GKPhotoBrowserHideStyleZoomScale;
browser.isResumePhotoZoom = YES;
browser.delegate = self;
[browser showFromVC:self];
}];
}];
}];
我们查看GKPhotoBrowser的图片加载方法:
- (void)loadImageWithPhoto:(GKPhoto *)photo isOrigin:(BOOL)isOrigin
发现,GKPhotoBrowser内部在加载图片的时候,会创建一个imageView,而这个imageView通过动态创建类型的,此时的类型正好是SDAnimatedImageView,于是继续查看SDAnimatedImageView.m文件发现下面方法:
- (void)displayLayer:(CALayer *)layer
在此方法中增加调用父类即可
[super displayLayer:layer];
网友评论