phfetchoptions

PHPickerViewController load videos via PHAsset

僤鯓⒐⒋嵵緔 提交于 2020-12-15 05:49:16
问题 PHPickerViewController allows access to copies of photo library assets as well as returning PHAssets in the results. To get PHAssets instead of file copies, I do: let photolibrary = PHPhotoLibrary.shared() var configuration = PHPickerConfiguration(photoLibrary: photolibrary) configuration.filter = .videos configuration.selectionLimit = 0 let picker = PHPickerViewController(configuration: configuration) picker.delegate = self self.present(picker, animated: true, completion: nil) And then, /

Swift 3 - Fetch All Photos From Library

亡梦爱人 提交于 2020-05-24 18:29:28
问题 I've tried to fetch photos from the library. It works, but I just got 3 photos from 9 photos from the library. Here's my code: let options = PHFetchOptions() let userAlbums = PHAssetCollection.fetchAssetCollections(with: PHAssetCollectionType.album, subtype: PHAssetCollectionSubtype.any, options: options) let userPhotos = PHAsset.fetchKeyAssets(in: userAlbums.firstObject!, options: nil) let imageManager = PHCachingImageManager() userPhotos?.enumerateObjects({ (object: AnyObject!, count: Int,

Swift 3 - Fetch All Photos From Library

折月煮酒 提交于 2020-05-24 18:29:10
问题 I've tried to fetch photos from the library. It works, but I just got 3 photos from 9 photos from the library. Here's my code: let options = PHFetchOptions() let userAlbums = PHAssetCollection.fetchAssetCollections(with: PHAssetCollectionType.album, subtype: PHAssetCollectionSubtype.any, options: options) let userPhotos = PHAsset.fetchKeyAssets(in: userAlbums.firstObject!, options: nil) let imageManager = PHCachingImageManager() userPhotos?.enumerateObjects({ (object: AnyObject!, count: Int,

get thumbnail images in list and full size image when click on the item of list

纵饮孤独 提交于 2019-12-25 08:27:50
问题 So I am using below code to fetch all the images from library which is working fine : func grabPhotos(){ let imgManager = PHImageManager.default() let requestOptions = PHImageRequestOptions() requestOptions.isSynchronous = true requestOptions.deliveryMode = .highQualityFormat let fetchOptions = PHFetchOptions() fetchOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: true)] if let fetchResults : PHFetchResult = PHAsset.fetchAssets(with: .image, options: fetchOptions){

NSPredicate to exclude slow motion videos from PHFetchResults

一个人想着一个人 提交于 2019-12-13 06:03:21
问题 NSString *predicateFormat = [NSString stringWithFormat: @"mediaSubtype = %zd", PHAssetMediaSubtypeVideoHighFrameRate]; NSPredicate *predicate = [NSPredicate predicateWithFormat: predicateFormat]; PHFetchOptions *fetchOptions = [PHFetchOptions new]; fetchOptions.predicate = predicate; PHFetchResult *userAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeSmartAlbumVideos options:fetchOptions]; This is my code to fetch videos

Swift iOS: -How to exclude .livePhotos from inclusion in the PHFetchOptions?

淺唱寂寞╮ 提交于 2019-12-13 05:49:40
问题 Following @matt's code when using the UIImagePicker , I can prevent the user from picking a .livePhoto once an image is choosen using: let asset = info[UIImagePickerControllerPHAsset] as? PHAsset if asset?.playbackStyle == .livePhoto { // alert user this photo isn't a possibility } When using the PHFetchOptions how can I prevent them from being shown instead of filtering them out inside the enumerateObjects callback? fileprivate func fetchPhotos() { let fetchOptions = PHFetchOptions()