photokit

When is PHFetchResultChangeDetails's “hasMoves” equal to YES?

独自空忆成欢 提交于 2019-12-13 03:48:01
问题 I'm writing my subclasses of PHChange along with PHFetchResultChangeDetails . I understand fields like insertedIndexes , insertedObjects , fetchResultBeforeChanges , fetchResultAfterChanges etc. What I can't understand is a field hasMoves . Documentation says that it's "A Boolean value that indicates whether objects have been rearranged in the fetch result" . So my questions are: 1. What should the user do to reproduce the case when hasMoves = YES ? 2. If hasMoves = YES can the moves be

Add assets to an iCloud shared photo album programmatically

丶灬走出姿态 提交于 2019-12-13 03:47:12
问题 Are there any limitations on using PhotoKit to add photos to Shared iCloud photo albums? While I can add new photos to AssetCollections that are regular albums, it does not work at all if the AssetCollection represents an iCloud sharing album. Do I also need to add a different type of PHAsset? If I change the fetchAssetCollections call to use .albumRegular instead of .albumCloudShared , the code below works. Otherwise I get an error: The operation couldn't be completed. (PHPhotosErrorDomain

IOS8. Photos application bug?

此生再无相见时 提交于 2019-12-12 09:55:34
问题 When I use filters in standard Photos application in IOS8, I can't get full metadata. I try two methods fetch metadata: [manager requestImageDataForAsset:asset options:options resultHandler:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) { CIImage *ciimage = [CIImage imageWithData:imageData]; NSMutableDictionary *exif = [NSMutableDictionary dictionary]; [exif addEntriesFromDictionary:ciimage.properties]; }]; [asset

PHImageResultIsDegradedKey/PHImageFileURLKey is not found

不羁岁月 提交于 2019-12-12 08:12:29
问题 iOS 13 beta4 no longer gives 1) PHImageFileURLKey 2) PHImageResultIsDegradedKey in image result info keys. Anyone knows a way to find the fileurl of the PHAsset? 回答1: You have to use this function from PHAsset object: - (PHContentEditingInputRequestID)requestContentEditingInputWithOptions:(nullable PHContentEditingInputRequestOptions *)options completionHandler:(void (^)(PHContentEditingInput *__nullable contentEditingInput, NSDictionary *info))completionHandler; Then you can retrieve URL

PHAsset: What is 'assetSource'?

情到浓时终转凉″ 提交于 2019-12-11 07:25:42
问题 I am enumerating a PHFetchResult. If I do a println on the PHAssets being returned, I get this: <PHAsset: 0x178192140> 4CBE5A4F-90BD-438B-954E-6FF1B14538CD/L0/001 mediaType=1/0, assetSource=3, (2448x3264), creationDate=2014-10-15 14:20:12 +0000, location=1, hidden=0, favorite=1 Does anyone know what the assetSource=3 bit is? I would like to run a predicate on the assetSource if possible but can't find any information anywhere on what it is or how to access it. Is it private? 回答1: assetSource

Modifying Metadata from PHAsset with mediaType Video fails

≡放荡痞女 提交于 2019-12-11 05:21:56
问题 I try adding/modifying the Metadata from an PHAsset with mediaType == .video I found some Questions refering to a similar problem: How to change video metadata using AVAssetWriter? Add custom metadata to video using AVFoundation Regarding to the Answers in these Questions I build the following snippet which is a extension of a PHAsset: let options = PHVideoRequestOptions() options.version = .original PHImageManager.default().requestAVAsset(forVideo: self, options: options, resultHandler: {

PHObject localIdentifier reliability

泪湿孤枕 提交于 2019-12-10 15:49:36
问题 Are there ever circumstances where the localIdentifier could change or not be accurate? I'm working on an application that backs up photos and have been told by my colleagues that the localIdentifier can't be trusted. However, after doing some research I have been unable to find anyone talking about this. 回答1: LocalIdentifiers sometimes change after updating the iOS version. I've seen the PHAsset.localIdentifiers (Photo API) change after iOS updates twice - in my own Apps. The last time was

Can fetchAssetCollectionsWithType's results be sorted when fetching smart albums?

一世执手 提交于 2019-12-10 09:28:35
问题 When calling fetchAssetCollectionsWithType I have no trouble getting properly sorted results for most collection types. For example: fetchOptions = [[PHFetchOptions alloc] init]; fetchOptions.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"localizedTitle" ascending:YES],]; PHFetchResult *topLevelUserCollections = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:fetchOptions]; I get all albums sorted

PHAsset Location — GPS MetaData, what's wrong?

偶尔善良 提交于 2019-12-10 07:32:49
问题 trying to add location from a UIImage using Phasset: // image is a variable like so: image: UIImage var newAsset = PHAssetChangeRequest.creationRequestForAssetFromImage(image) newAsset.location = CLLocation(latitude: coordinate.latitude, coordinate.longitude) this code works, apparently -> save a new asset into the photo library with the good coordinate. I can see it in the library itself. but when I use exif tools and similar, most of the time, GPS dictionnary is empty as if location was not

How to know if an PHAssetCollection is the recently deleted collection?

给你一囗甜甜゛ 提交于 2019-12-09 19:08:02
问题 There is a subtype for the recently added collection: PHAssetCollectionSubtypeSmartAlbumRecentlyAdded . However there is no assetCollectionSubtype that would identify the "Recently Deleted" collection. This is the description of the "Recently Deleted" collection in my case: (iOS 8.1.3): DF876BFD-...-C97F4628467C/L0/040 Recently Deleted assetCollectionType=2/1000000201 This indicates it is of type PHAssetCollectionTypeSmartAlbum . But what the heck is subtype 1000000201 ? 201 should be