Questions tagged [photosframework]

This tag should only be used for questions related to the Photos framework available in iOS, macOS, and tvOS.

The Photos framework is an framework for retrieval of assets for display and playback, editing their image or video content, and working with collections of assets such as albums, moments, and iCloud Shared Albums.

Photos.framework is available as of iOS 8.0, macOS 10.13, and tvOS 10.0.

In iOS, the Photos framework replaces the now deprecated AssetsLibrary framework.

267 questions
59
votes
11 answers

PHImageManager requestImageForAsset returns nil sometimes for iCloud photos

Roughly 10% of the time PHImageManager.defaultManager().requestImageForAsset returns nil instead of a valid UIImage after first returning a valid though "degraded" UIImage. No error or other clue that I can see is returned in the info with the nil.…
LenK
  • 2,944
  • 2
  • 20
  • 26
52
votes
3 answers

Get an error when trying to get all the photos from PHAssetCollection.fetchAssetCollections

I want to get all the photos of my custom album. but instead what I get is the below error. My Code let collections:PHFetchResult = PHAssetCollection.fetchAssetCollections(with: .album, subtype: .any, options: fetchOptions) Error i get "Error…
Björn Lindner
  • 521
  • 1
  • 4
  • 4
40
votes
10 answers

NSURL from PHAsset

I'm converting our app over to use the Photos Framework of iOS8, the ALAsset framework is clearly a second class citizen under iOS8. I'm having a problem is that our architecture really wants an NSURL that represents the location of the media on…
Paul Cezanne
  • 8,629
  • 7
  • 59
  • 90
26
votes
8 answers

Photos Framework. requestImageForAsset returning two results. Can't set image view

So I am using the SwipeView library (https://github.com/nicklockwood/SwipeView) to show images using the Photos framework for iOS8. However, when I call the requestImageForAsset I notice I am getting two results, a thumbnail size, and the bigger…
Jonovono
  • 1,979
  • 7
  • 30
  • 53
25
votes
8 answers

How to get only images in the camera roll using Photos Framework

The following code loads images that are also located on iCloud or the streams images. How can we limit the search to only images in the camera roll? var assets = PHAsset.fetchAssetsWithMediaType(PHAssetMediaType.Image, options: nil)
William Falcon
  • 9,813
  • 14
  • 67
  • 110
21
votes
4 answers

Photos Framework requestImageDataForAsset occasionally fails

I'm using the photos framework on iOS8.1 and requesting the image data for the asset using requestImageDataForAsset... Most of the time it works and I get the image data and a dictionary containing what you see below. But sometimes the call…
Dan Loughney
  • 4,647
  • 3
  • 25
  • 40
21
votes
5 answers

How to fetch squared thumbnails from PHImageManager?

Has anybody idea how to fetch squared thumbs from PHImageManager? PHImageContentModeAspectFill option has no effect. [[PHImageManager defaultManager] requestImageForAsset:(PHAsset *)_asset targetSize:CGSizeMake(80, 80) …
Pavel Osipov
  • 2,067
  • 1
  • 19
  • 27
20
votes
5 answers

Photos Framework crash: 'This application is not allowed to access Photo data.'

App crashes if photo access permission is not granted and the object which asked for permission is about to deallocate. Apple's sample code (for Photos framework) crashes too. My app crashes with following stack trace: *** Terminating app due to…
O Fenômeno
  • 445
  • 3
  • 14
20
votes
6 answers

Get the local file path of a PHAsset

I have a photo I want my user to be able to share on Instagram and I need to get the local file directory of the photo. However I am fetching my images as a PHAsset (not the ALAsset all the other answers seem to cover on this subject). Looking at…
Aggressor
  • 13,323
  • 24
  • 103
  • 182
19
votes
7 answers

Check given PHAsset is iCloud asset?

I'm trying to get PhAsset object. I want to segregate iCloud assets. Here is my code, PHFetchResult *cloudAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAny…
rishu1992
  • 1,414
  • 3
  • 14
  • 33
19
votes
6 answers

AssetsLibrary framework broken on iOS 8

I have run into an issue on iOS 8 with the Assets Library framework that appears to be a bug in iOS 8. If I create an album called 'MyMedia' and then delete it, then when I try to create the album again, this chunk of code below returns 'nil'…
Adam Freeman
  • 1,271
  • 12
  • 20
17
votes
4 answers

Save a big batch of photos using the new Photos framework?

I'm trying to save a big batch of photos into the Photos library using the new PHAssetChangeRequest class in iOS 8. Problem is, it looks like the daemon that saves the photos is itself crashing unexpectedly with a moderately large number of photos…
Dhiraj Gupta
  • 9,704
  • 8
  • 49
  • 54
15
votes
2 answers

Attach custom thumbnail for a video (not extract) - IOS, AVFoundation

I generate video by using AVFoundation. After that I write video to the Photos library by using Photos Framework (and get instance of PHAsset after that). I want to set custom thumbnail for added PHAsset (last frame from the video), but can't…
Andrew Romanov
  • 4,774
  • 3
  • 25
  • 40
15
votes
2 answers

Error: 'Unsupported predicate in fetch options: mediaType == 2'

I'm trying to use smartAlbum to generate an array of either only videos or only photos or both. You can see my code below: PHFetchResult *collectionList = [PHCollectionList fetchMomentListsWithSubtype:PHCollectionListSubtypeMomentListCluster…
Anish Kumar
  • 1,465
  • 16
  • 20
14
votes
1 answer

How to use PHPhotoLibrary like ALAssetsLibrary

For iOS9, ALAssetsLibrary is deprecated. So how to change it as PHPPhotoLibrary instead of ALAssets? if (RecordedSuccessfully && recording == NO) { //----- RECORDED SUCESSFULLY ----- NSLog(@"didFinishRecordingToOutputFileAtURL - success"); …
dicle
  • 1,122
  • 1
  • 12
  • 40
1
2 3
17 18