photosframework

How to retrieve photo extension (jpg/png) in iOS 8.0 using Photos API?

眉间皱痕 提交于 2019-12-04 10:09:03
Am trying to get file extension of photos using the new Photos API in iOS 8 but haven't found a way to do so until now. Before iOS 8.0 I would use ALAssetRepresentation to get the file extension like: // Get asset representation from asset ALAssetRepresentation *assetRepresentation = [asset defaultRepresentation]; // Extract file extension from the original file name NSString* fileExt = [[assetRepresentation filename] pathExtension]; Is there any way to get file extension of photos now? PS: I am using new Photos API as I need to access all photos in my photos app, and ALassetsLibrary gives

Check given PHAsset is iCloud asset?

江枫思渺然 提交于 2019-12-04 09:28:54
问题 I'm trying to get PhAsset object. I want to segregate iCloud assets. Here is my code, PHFetchResult *cloudAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAny options:nil]; [cloudAlbums enumerateObjectsUsingBlock:^(PHAssetCollection *collection, NSUInteger idx, BOOL *stop){ if(collection != nil){ PHFetchResult *result = [PHAsset fetchAssetsInAssetCollection:collection options:fetchOptions]; [result enumerateObjectsUsingBlock:

deleting a camera roll asset using Photos framework

旧时模样 提交于 2019-12-04 07:26:45
I'm writing a test application to see if it is possible to delete a "photo library" asset in iOS 8, using the Photos framework. Although I suspect it is not possible, I find the documentation to be unclear, and there are posts on this site that seem to indicate it is possible. See here for example. In my test app, I pick an asset from the library: var picker = UIImagePickerController() picker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary picker.mediaTypes = [kUTTypeMovie] In the delegate callback, I get the NSURL of the asset, and put it into an array: let thePicked = info

Photos framework: Connection to assetsd was interrupted or assetsd died

心不动则不痛 提交于 2019-12-03 12:55:28
I am getting this error when I am trying to play multiple videos using this swift library ( https://github.com/piemonte/player ). Not sure if it's related to that player, or to the Photos framework or what though. What happens is, I have a view that will display either a photo or a video. Everything works fine a few times until a few videos have played and then this message will pop up, followed by all the videos not being able to play and in their place you just see a black screen, and then I get a memory usage error. I am using a library called SwipeView and here is some relevant code which

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

狂风中的少年 提交于 2019-12-03 11:39:27
问题 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 options:nil]; PHFetchOptions *options = nil; if (self.xSelected) { options = [[PHFetchOptions alloc] init]; options.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:NO]]; options.predicate = [NSPredicate

Upload videos from gallery using Photos framework

时光毁灭记忆、已成空白 提交于 2019-12-03 09:44:55
问题 What is the best way to upload videos from gallery using Photos framework? Before I used ALAssetRepresentation and next method: - (NSUInteger)getBytes:(uint8_t *)buffer fromOffset:(long long)offset length:(NSUInteger)length error:(NSError **)error; this allowed to upload file without first copying it to app temp directory. Don’t see any alternatives in Photos framework. Only way seems to use AVAssetExportSession -> export to local directory -> upload, but this requires additional storage

How to fetch squared thumbnails from PHImageManager?

▼魔方 西西 提交于 2019-12-03 03:49:14
问题 Has anybody idea how to fetch squared thumbs from PHImageManager? PHImageContentModeAspectFill option has no effect. [[PHImageManager defaultManager] requestImageForAsset:(PHAsset *)_asset targetSize:CGSizeMake(80, 80) contentMode:PHImageContentModeAspectFill options:nil resultHandler:^(UIImage *result, NSDictionary *info) { // sadly result is not a squared image imageView.image = result; }]; 回答1: Update: The bug in cropping images as they were retrieved from PHImageManager was fixed in iOS 8

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

时光怂恿深爱的人放手 提交于 2019-12-03 01:59:52
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 options:nil]; PHFetchOptions *options = nil; if (self.xSelected) { options = [[PHFetchOptions alloc] init]; options.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:NO]]; options.predicate = [NSPredicate predicateWithFormat:@"mediaType = %d",PHAssetMediaTypeImage]; } if (self.ySelected) { options = [[PHFetchOptions

Upload videos from gallery using Photos framework

有些话、适合烂在心里 提交于 2019-12-03 01:20:23
What is the best way to upload videos from gallery using Photos framework? Before I used ALAssetRepresentation and next method: - (NSUInteger)getBytes:(uint8_t *)buffer fromOffset:(long long)offset length:(NSUInteger)length error:(NSError **)error; this allowed to upload file without first copying it to app temp directory. Don’t see any alternatives in Photos framework. Only way seems to use AVAssetExportSession -> export to local directory -> upload, but this requires additional storage space (could be a problem, if video is too big) Seems the only valid way is to request AVAsset from

Delete in PhotoKit: can you skip “Recently Deleted”?

主宰稳场 提交于 2019-12-01 09:02:43
As of iOS8, when you delete a photo, it goes into a trashcan-analog called "Recently Deleted". This happens when you delete via Photos.app, or via the PhotoKit API (using PHAssetChangeRequest.deleteAssets() ). In Photos.app, you can then go into "Recently Deleted", and really delete that photo. Is there a way to do that in PhotoKit? Nope. The only deletion API is deleteAssets . 来源: https://stackoverflow.com/questions/26934777/delete-in-photokit-can-you-skip-recently-deleted