longitachi / ZLPhotoBrowser

Wechat-like image picker. Support select photos, videos, gif and livePhoto. Support edit image and crop video. 微信样式的图片选择器,支持预览/相册内拍照及录视频、拖拽/滑动选择,编辑图片/视频,支持多语言国际化等功能;
MIT License
4.72k stars 953 forks source link

调用ZLImagePreviewController预览图片后,再用showPhotoLibrary就只显示视频不显示照片 #799

Closed aluzi992 closed 1 year ago

aluzi992 commented 1 year ago

Issue Description

Description and Steps

直接运行showPhotoLibrary是正常的,能显示所有的视频和照片。 但是如果先运行ZLImagePreviewController去预览一些图片,然后关掉,再运行showPhotoLibrary,就只能够显示视频了,照片全部不见了。此时即使关闭了控制器再重新打开也一样

Info

ZLPhotoBrowser version: 4.3.8 Device: iPhone 14Pro Device version: iOS 16.2 Xcode version: Xcode 14.0

Configuration code of ZLPhotoConfiguration

//在同一个控制器里面,先运行下面的代码预览指定的图片
           let videoSuffixs = ["mp4", "mov", "avi", "rmvb", "rm", "flv", "3gp", "wmv", "vob", "dat", "m4v", "f4v", "mkv"] // and more suffixs
        let vc = ZLImagePreviewController(datas: datas, index: index, showSelectBtn: false,showBottomView: false) { (url) -> ZLURLType in
            if let sf = url.absoluteString.split(separator: ".").last, videoSuffixs.contains(String(sf)) {
                return .video
            } else {
                return .image
            }
        } urlImageLoader: { (url, imageView, progress, loadFinish) in
            // Demo used Kingfisher.            
            imageView.kf.setImage(with: url,options: [.requestModifier(modifier)]) { (receivedSize, totalSize) in
                let percentage = (CGFloat(receivedSize) / CGFloat(totalSize))
                progress(percentage)
            } completionHandler: { (_) in
                loadFinish()
            }
        }        
        vc.doneBlock = { (datas) in
        }

        let config=ZLPhotoConfiguration.default()
        config.allowEditImage=false
        config.allowSelectImage=false
        vc.modalPresentationStyle = .fullScreen
        self.showDetailViewController(vc, sender: nil)

//关掉预览窗口,然后再调用showPhotoLibrary调出相册,就会只显示视频,照片全部没有了:
        let ps = ZLPhotoPreviewSheet()
        let config=ZLPhotoConfiguration.default()
        config.allowEditImage=true
        config.allowSelectOriginal=true
        config.maxSelectCount=9
        ps.selectImageBlock = { [weak self] results, isOriginal in        
        }
        ps.showPhotoLibrary(sender: self)
longitachi commented 1 year ago

因为你设置了allowSelectImage = false,建议每次配置ZLPhotoConfiguration之前先调用ZLPhotoConfiguration.resetConfiguration()

aluzi992 commented 1 year ago

谢谢!的确是这个原因。