objective-c - PHFetchOptions 持续时间无法正常工作

标签 objective-c swift nspredicate phasset phfetchoptions

我正在尝试获取所有时长超过 1.5 秒的视频

我尝试过的

        let videoOptions = PHFetchOptions()
        let dur : Double = 1.5
        videoOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: false)]
        videoOptions.predicate = NSPredicate(format: "mediaType = %d AND duration > %d", PHAssetMediaType.Video.rawValue,dur)
        VideoCollectionFetchResult =  PHAsset.fetchAssetsWithOptions(videoOptions) 

文档说:

enter image description here

有什么建议吗?谢谢!

最佳答案

与格式有关——duration实际上是Double格式,%d是整数。尝试使用 %f,例如:

(format: "mediaType = %d AND duration > %f", PHAssetMediaType.Video.rawValue,dur)

关于objective-c - PHFetchOptions 持续时间无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36718262/

相关文章:

html - UIWebView 正确显示远程页面,但在 objective-c 中不显示本地页面

iphone - xcode 4.5 中的 dictionaryHasDefinitionForTerm 问题

ios - 在创建时调整自定义 UITableViewCell 的 subview

swift - viewDidLoad 中设置的变量稍后变为 nil

ios - swift 图片从URL下载到本地存储

objective-c - 将文档预加载到 iOS 应用程序中

swift - UIScrollview 不适用于 Storyboard

cocoa - 在应用 NSPredicate 时转换 NSDictionary 值?

ios - 在 Xcode Beta 6 之后快速使用 NSPredicate 崩溃

regex - 使用正则表达式检查字符串中的第三个字符