fix(album): prevent black screen when switching preview variants

This commit is contained in:
2026-08-10 16:28:00 +08:00
parent 439edf827c
commit 3b88b9cde9
2 changed files with 60 additions and 5 deletions
@@ -639,11 +639,6 @@ private final class TravelAlbumPreviewImageCell: UICollectionViewCell, UIScrollV
resetZoom()
}
override func layoutSubviews() {
super.layoutSubviews()
imageView.frame = scrollView.bounds
}
func apply(asset newAsset: TravelAlbumPreviewAsset?) {
asset = newAsset
resetZoom()
@@ -687,6 +682,7 @@ private final class TravelAlbumPreviewImageCell: UICollectionViewCell, UIScrollV
imageView.contentMode = .scaleAspectFit
imageView.backgroundColor = .black
imageView.kf.indicatorType = .activity
imageView.accessibilityIdentifier = "travelAlbum.previewImageView"
retryButton.setTitle("图片加载失败,点击重试", for: .normal)
retryButton.setTitleColor(UIColor.white.withAlphaComponent(0.82), for: .normal)
@@ -699,6 +695,11 @@ private final class TravelAlbumPreviewImageCell: UICollectionViewCell, UIScrollV
scrollView.addSubview(imageView)
contentView.addSubview(retryButton)
scrollView.snp.makeConstraints { $0.edges.equalToSuperview() }
imageView.snp.makeConstraints { make in
make.edges.equalTo(scrollView.contentLayoutGuide)
make.width.equalTo(scrollView.frameLayoutGuide)
make.height.equalTo(scrollView.frameLayoutGuide)
}
retryButton.snp.makeConstraints { $0.center.equalToSuperview() }
let singleTap = UITapGestureRecognizer(target: self, action: #selector(singleTapped))