2017-06-23 41 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