ios - Fetch only photos of type PHAssetMediaTypeImage form asset collection type PHAssetCollectionTypeSmartAlbum -


I am using a photo framework to bring an album list to iOS 8. I

  PHFetchResult * using smartAlbums ='m for it [: PHAssetCollectionTypeSmartAlbum subtype: PHAssetCollectionSubtypeAlbumRegular options: PHAssetCollection fetchAssetCollectionsWithType zero];  

This gives me a list of all Smart Albums, including videos. How can I filter video from this list? I only need images

Support will be appreciated. Thank you.

Options bringing you should set its property predicate , which Can be used to filter video. An example

  PHFetchResult * smartAlbums = [PHAssetCollection fetchAssetCollectionsWithType: PHAssetCollectionTypeSmartAlbum subtype: PHAssetCollectionSubtypeAlbumRegular alternative is below zero]; // Get the Setup Options, Media Type Image is PHFetchOptions * Options = [[PHFetchOptions alloc] init]; Options.sortDescriptors = @ [[NSSortDescriptor sortDescriptorWithKey: @ "creation date" ascending: no]]; Options.predicate = [NSPredicate predicateWithFormat: @ "mediaType =% d", PHAssetMediaTypeImage]; (; I & LT; smartAlbums.count; NSInteger i = 0 i {PHAssetCollection for ++) * assetCollection = smartAlbums [i]; PHFetchResult * assetsFetchResult = [PHAsset fetchAssetsInAssetCollection: Property Selection Options: Options]; NSLog (@ "Sub Album Title is% @, count is% ld", assetCollection.localizedTitle, assetsFetchResult.count); If (assetsFetchResult.count> {} (for assets; FATCHResult in PHAsset * property) {// you've got your image type property. }}}  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -