phasset

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

淺唱寂寞╮ 提交于 2019-12-13 05:49:40
问题 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 user this photo isn't a possibility } When using the PHFetchOptions how can I prevent them from being shown instead of filtering them out inside the enumerateObjects callback? fileprivate func fetchPhotos() { let fetchOptions = PHFetchOptions()

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

How to get the path of an image?

倾然丶 夕夏残阳落幕 提交于 2019-12-12 05:00:00
问题 How can I get the path or directory of the PHAsset images? I came across an answer here written by @diegomen but when I try it like selectedAssets[0].PHAsset.getURL() it asks for a parameter but @diegomen said it doesn't require a parameter from the comments. Am I applying it wrong? Or is there other way of getting the images path from PHAsset ? NOTE: I found another solution here by @Clay but it doesn't seem to be the good practice to do it. 回答1: If you have already store image in your local

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

Create folder in custom photo album

浪子不回头ぞ 提交于 2019-12-11 02:24:12
问题 I have a custom album in which my app saves picture from camera. I am wondering if there is a way I can create folders inside my album so I can stack certain images inside it? ANSWER As fellow members mentioned, sadly there is no way you can create a folder inside album. 回答1: You should try code below. It's Swift 3.0 syntaxe. :) import Foundation import Photos class CustomPhotoAlbum: NSObject { static let albumName = "Album Name" static let sharedInstance = CustomPhotoAlbum() var

Hide UIProgressView after fetch for PHAsset is completed and progress finished animating

不问归期 提交于 2019-12-10 14:41:28
问题 I'm performing a request to get an image asset given a PHAsset , and I'm using UIProgressView to indicate the progress using the progressHandler PHImageRequestOptions allows me to provide. When that handler is called, it provides me with progress so I set the progress on the progress view but I also animate to that new progress via setProgress:animated: . I now need to figure out how to hide the progress view once progress has reached 1.0, but not until it has finished animating to 1.0. For

How to compare PHAsset to UIImage

对着背影说爱祢 提交于 2019-12-10 10:17:15
问题 I have converted some PHAsset to UIImage : PHImageManager *manager = [PHImageManager defaultManager]; [manager requestImageForAsset:asset targetSize:PHImageManagerMaximumSize contentMode:PHImageContentModeDefault options:requestOptions resultHandler:^void(UIImage *image, NSDictionary *info) { convertedImage = image; [images addObject:convertedImage]; }]; Now I want to do something like that: [selectedAssets removeObject:image]; where selectedAssets is an array of PHAsset and image is an

How to get all PHAssets from MacOS's Photo Library

*爱你&永不变心* 提交于 2019-12-10 10:16:43
问题 I want to parse all images from my MacOS Photos Library, using PHAsset. However all examples I find are only working for iOS, like the one below, where the last line, which retrieves the assets is not available on macos framework: NSMutableArray *photos = [[NSMutableArray alloc] init]; PHFetchOptions *allPhotosOptions = [[PHFetchOptions alloc] init]; allPhotosOptions.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:YES]]; // Below compilation error as

Get the local file path of a PHAsset

泪湿孤枕 提交于 2019-12-10 00:47:59
问题 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 the PHAsset documentation I don't see a 'local directory' variable. Do you know how I can get the path to a photo from the users camera roll using the new ios8 Photo's framework? Here is my code for loading the last image in the users photo roll

Sharing Video PHAsset via UIActivityController

我只是一个虾纸丫 提交于 2019-12-09 16:55:38
问题 I am trying to share video PHAsset via UIActivityController using requestAVAsset. This works with Messaging, but not with AirDrop, indicating as 'Failed'. PHCachingImageManager.default().requestAVAsset(forVideo: asset, options: nil, resultHandler: { (givenAsset, audioMix, info) in let videoAsset = givenAsset as! AVURLAsset let videoURL = videoAsset.url DispatchQueue.main.async { let activityViewController = UIActivityViewController( activityItems: [videoURL], applicationActivities: nil)