[PHCachingImageManager]를 사용하여 비디오를 컬렉션보기로 캐시합니다. 캐시 관리자로 생성 된 이미지를 표시 할 수 있지만 AVAssets를 가져 오지 않습니다.PHCacheImageManager.requestAVAsset (forVideo : ...)는 nil AVAsset을 반환합니다.
.requestAVAsset (forVideo : ...) 메서드를 사용하여 AVAsset을 가져 오려고하지만 결과 처리기에 반환 된 [asset]이 nil입니다. 반환 된 [저작물]을 unwrap하려고 할 때 오류가 발생합니다.
[audioMix] 및 [info] 매개 변수가 결과 처리기에 반환 된 것으로 보아도 아무 것도 없었습니다. 아무도 내가 뭘 잘못하고/여기에 실종 알아?
viewDidLoad() {
let videosAlbum = PHAssetCollection.fetchAssetCollections(with: .smartAlbum, subtype: .smartAlbumVideos, options: nil)
self.videoAssets = PHAsset.fetchAssets(in: videosAlbum.object(at: 0), options: nil)
self.imgCacheManager.startCachingImages(for: self.videoAssets.objects(at: [0, videoAssets.count-1]), targetSize: CGSize(width: 150, height: 150), contentMode: .aspectFit, options: nil)
}
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let selectedAsset = self.imgCacheManager.requestAVAsset(forVideo: self.videoAssets.object(at: indexPath.item), options: nil, resultHandler: {
asset,_,_ in
self.delegate.selectedVideo(Asset: asset!) // this is the line I get the error
})
}
내 대표는 선택 사항이지만 확실히 거기에 뭔가를 가지고, 그래서 그 오류를 던지고는 미개봉 [자산]입니다 확신합니다.
감사합니다! 나는 코드를 Swift4로 업그레이드 한 후이 문제에 직면했다.'options.isNetworkAccessAllowed = true'가 도움이되었다. –