Questions tagged [phfetchoptions]

29 questions
19
votes
3 answers

Swift 3 - Fetch All Photos From Library

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:…
catcatcat
  • 377
  • 1
  • 5
  • 19
7
votes
1 answer

PHFetchResult get all photos and sort by date inconsistent

I'm trying to build a simply photo picker that has two options for now: Recents and Favorites. What I'm doing is trying to get all the photos by the creationDate however this is giving back images in the wrong order in my data source. There's photos…
klcjr89
  • 5,862
  • 10
  • 58
  • 91
5
votes
2 answers

Fetch only albums in a PHCollectionList

A PHCollectionList is a folder that could contain any number of albums and/or folders. I am currently fetching the collections within the list via PHCollection.fetchCollectionsInCollectionList(list, options: nil). This could return objects of type…
Jordan H
  • 52,571
  • 37
  • 201
  • 351
4
votes
1 answer

PHPickerViewController load videos via PHAsset

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 =…
Deepak Sharma
  • 5,577
  • 7
  • 55
  • 131
3
votes
2 answers

PHFetchOptions() Photos Only Using PHAsset & PHAssetCollection

I am using a chunk from Apple's sample code here: override func awakeFromNib() { // Create a PHFetchResult object for each section in the table view. let allPhotosOptions = PHFetchOptions() allPhotosOptions.sortDescriptors =…
Gizmodo
  • 3,151
  • 7
  • 45
  • 92
2
votes
1 answer

Videos and its thumbnails not saved in sequence after fetching From Photos

I am using below code for getting videos(URL, Durations, Thumbnails). After Fetching data i am displaying it on CollectionView. The main problem is that, some video and its thumbnails not match each other. Can any one please tell me how i can fix…
ZAFAR007
  • 3,049
  • 1
  • 34
  • 45
2
votes
2 answers

Swift fetchAssetsInAssetCollection: Loading Photos From Range in Camera Roll

I want the user to have the ability to access all of their photos, but loading them all at once takes too long using PHAsset.fetchAssetsInAssetCollection, especially if they have 500+ photos (I am displaying them in a collection view in a…
Kiley
  • 409
  • 1
  • 5
  • 19
2
votes
3 answers

NSPredicate to exclude slow motion videos from PHFetchResults

NSString *predicateFormat = [NSString stringWithFormat: @"mediaSubtype = %zd", PHAssetMediaSubtypeVideoHighFrameRate]; NSPredicate *predicate = [NSPredicate predicateWithFormat: predicateFormat]; PHFetchOptions *fetchOptions =…
rishu1992
  • 1,414
  • 3
  • 14
  • 33
1
vote
0 answers

PHAsset's modificationDate changes every time on fetching from iOS Photos app

I am fetching PHAsset using localIdentifier and observing that PHAsset modificationDate is changes every time let options = PHFetchOptions() options.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: true)] if let asset =…
Mohd Haider
  • 673
  • 1
  • 5
  • 25
1
vote
1 answer

Swift: how to fetch all photos (PHAsset) except Screenshots, Burst, Live?

I want to fetch all photos (PHAsset) except Screenshots, Burst, Live photos from Photo library. I tried with code below but it returns Screenshots, Burst, Live photos let options = PHFetchOptions() options.sortDescriptors = […
1
vote
1 answer

Swift 4 NSPredicate date format not working

I am trying to fetch photos and videos from the users camera roll, taken within the last 7 days. Here is my code... let oneWeekAgoDate = NSCalendar.current.date(byAdding: .weekOfYear, value: -1, to: NSDate() as Date) fetchOptions.predicate =…
Dan
  • 543
  • 2
  • 13
1
vote
2 answers

Why don't the photos appear during the initial launch of the app?

I have implemented a viewController which contains a collectionView that holds photos from the users photo album saved on their phone. On the very first launch of the app after the app asks for the users permission to access their photos the photos…
1
vote
0 answers

PHFetchOptions include only photos from iPhone camera

Right now I use that to exclude Screenshots: let options = PHFetchOptions() options.predicate = NSPredicate(format: "NOT (mediaSubtype & \(PHAssetMediaSubtype.photoScreenshot.rawValue) != 0)") var fetchResult: PHFetchResult = fetchResult =…
Paul T.
  • 4,938
  • 7
  • 45
  • 93
1
vote
1 answer

NSPredicate to not include Loop and Bounce Live Photos

In my app I only show assets the user can edit, so I only show photos - no videos. New in iOS 11 Live Photos have two effects that effectively turn the photo into a video - Loop and Bounce. These Live Photos cannot be edited in the Photos app - the…
Jordan H
  • 52,571
  • 37
  • 201
  • 351
1
vote
1 answer

How to save a video to the camera roll and get the asset URL?

I need to export a video from my iOS app and get the asset id. In the past, you can use ALAssetsLibrary: save image in camera roll and get asset url But it's deprecated now. I wonder what would be the new way of achieving this now? Thanks!
Thinium
  • 171
  • 1
  • 14
1
2