2017-06-23 38 views
0

在我的应用程序,我只显示用户可以编辑的资产,所以我只显示照片 - 没有视频。 iOS 11新增功能Live Photos具有两种可将照片有效转换为视频的效果 - 循环和跳动。这些实时照片无法在照片应用中编辑 - 插件按钮被禁用。我需要在我的PHFetchResult中筛选出来。但imagemediaType仍包含这些'实时视频'。我怎样才能从抓取中排除这些?可能与PHAssetplaybackStyle有关?NSPredicate不包括循环和反弹现场照片

let photoLibraryFetchResult = PHAssetCollection.fetchAssetCollections(with: .smartAlbum, subtype: .smartAlbumUserLibrary, options: nil) 
let assetCollection = photoLibraryFetchResult.firstObject! 

let imagesOnlyFetchOptions = PHFetchOptions() 
imagesOnlyFetchOptions.predicate = NSPredicate(format: "mediaType = %d", PHAssetMediaType.image.rawValue) 

let assetsFetchResults = PHAsset.fetchAssets(in: assetCollection, options: imagesOnlyFetchOptions) 

回答

0

试试看playbackStyle值。 (Read more here

枚举具有以下选项:

case image 
case imageAnimated 
case livePhoto 
case unsupported 
case video 
case videoLooping 
+0

酷,这样做的语法是:'NSPredicate(格式为: “playbackStyle =%d或playbackStyle =%d”,PHAsset.PlaybackStyle.image .rawValue,PHAsset.PlaybackStyle.livePhoto.rawValue)' – Joey