Questions tagged [phfetchoptions]

29 questions
1
vote
2 answers

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

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 …
Sumeet Purohit
  • 657
  • 1
  • 7
  • 16
1
vote
2 answers

PHFetchOptions Duration not working properly

I'm trying to fetch all the Videos which their duration is higher than 1.5 sec. What i have tried let videoOptions = PHFetchOptions() let dur : Double = 1.5 videoOptions.sortDescriptors = [NSSortDescriptor(key:…
Roi Mulia
  • 5,626
  • 11
  • 54
  • 105
1
vote
1 answer

Limit PHAsset fetch result to only 3 assets

I need to fetch three photos sorted by the date taken - latest being the most recently taken. The way I am currently doing this is by fetching all photo assets then fetching the asset at the appropriate indexes (0, 1, 2). While this works, I am…
Jordan H
  • 52,571
  • 37
  • 201
  • 351
0
votes
1 answer

What are the available NSSortDescriptors for PHFetchOptions?

I'm working with Apple's sample code for PhotoBrowse. In the main view controller's viewDidLoad() method we have this code: let allPhotosOptions = PHFetchOptions() allPhotosOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending:…
0
votes
2 answers

Get video metadata, how to detect whether the video is taken from front- or back-camera

I want to know whether is video is taken from the front or back camera. As info return nil. let asset: PHAsset! let manager = PHImageManager.default() if asset.mediaType == .video { let options: PHVideoRequestOptions =…
Prashant Ghimire
  • 518
  • 4
  • 20
0
votes
1 answer

Swift - Initializer for conditional binding must have Optional type, not 'PHFetchResult'

After updating the Xcode to 12.3, I'm getting the error "Initializer for conditional binding must have Optional type, not 'PHFetchResult'", its was working before as expected in previous versions. func fetchRecentPhotos() { if…
Manojkanth
  • 1,071
  • 11
  • 27
0
votes
1 answer

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

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…
Lance Samaria
  • 17,576
  • 18
  • 108
  • 256
0
votes
1 answer

How do you fetch only favorite pictures using Objective C's PHFetchOptions

I can fetch photos in a certain date range by doing this, but how can I further filter by their favorite statuses? PHFetchOptions *fetchOptions = [PHFetchOptions new]; fetchOptions.predicate = [NSPredicate predicateWithFormat:@"(creationDate >= %@)…
tsuyoski
  • 614
  • 5
  • 22
0
votes
1 answer

How to set an offset to PHAsset.fetchAssets?

This is my code to fetch images from the device gallery. let imgManager = PHImageManager.default() let requestOptions = PHImageRequestOptions() //loading all the images requestOptions.isSynchronous = false //Quality of the image …
0
votes
1 answer

How do I fetch images from photo library?

Hi I had switch from swift 2 to swift 3. Here is my uploadVC class PhotoUploadVC: UICollectionViewController { fileprivate var assets: PHFetchResult? fileprivate var sideSize: CGFloat! //It is snippet of viewDidLoad() override…
Shawn Baek
  • 1,928
  • 3
  • 20
  • 34
0
votes
0 answers

Error in Fetching image from photo gallery: [__NSCFString objectID]: unrecognized selector sent to instance

I am having trouble while fetching an image using NSPredicate to filter for matching image names. The code crashes at PHFetchReult *fetchResult. Error message is: 2016-09-15 00:51:25.112 PICTAG[1122:971448] -[__NSCFString objectID]: unrecognized…
TEZZ
  • 179
  • 1
  • 15
0
votes
1 answer

PHFetchResult for Custom Album Only

I'm simply trying to access the photos located in a custom folder called "MyFolder" to my UICollectionView. I can easily get this working with "all photos and videos" with the following code, but I can not figure out how to filter the results to…
Ibdakine
  • 504
  • 4
  • 17
0
votes
2 answers

Getting last picture taken from users photo library returning two pictures

When using the following code, it gets my last picture, but it duplicates it. It always gets the last picture, but it returns in a pair: UIImageView *imageView = (UIImageView *) [self.photoCollectionView viewWithTag:101]; PHFetchOptions…
Jteve Sobs
  • 244
  • 1
  • 14
0
votes
1 answer

PhotoKit: includeAllBurstAssets in PHFetchOptions not working

I am trying to use the includeAllBurstAssets of PHFetchOptions. In my camera roll, there are about 5 burst assets (each with about 10 photos). To enumerate the assets in the Camera Roll I'm doing the following: PHFetchOptions *fetchOptions =…
holtmann
  • 6,043
  • 32
  • 44
1
2