我遇到了一个问题。以前albums
输入有15个smartAlbum
,但随着,数字变成了。从那里消失了。这里获取相册的代码: AssetCollection
iOS 13
iOS 13
14
Camera Roll
func loadAlbums() {
var albums:[AlbumModel] = [AlbumModel]()
let options = PHFetchOptions()
let userAlbums = PHAssetCollection.fetchAssetCollections(with: .smartAlbum, subtype: .any, options: options)
userAlbums.enumerateObjects { [weak self] (object: AnyObject!, count: Int, stop: UnsafeMutablePointer) in
if object is PHAssetCollection {
let obj: PHAssetCollection = object as! PHAssetCollection
let fetchOptions = PHFetchOptions()
fetchOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: false)]
fetchOptions.predicate = NSPredicate(format: "mediaType = %d", PHAssetMediaType.image.rawValue)
if let arrayAllowedTypes = self?.arrayAllowedSubtypesRawValues, arrayAllowedTypes.contains(obj.assetCollectionSubtype.rawValue) {
let photos = PHAsset.fetchAssets(in: obj, options: fetchOptions)
let newAlbum = AlbumModel(name: obj.localizedTitle ?? String.empty, count: photos.count, collection:obj, firstAsset: photos.firstObject)
albums.append(newAlbum)
}
}
}
allowedAlbums = albums
selectedAlbum = albums.first(where: { (album) -> Bool in
album.collection.assetCollectionSubtype.rawValue == 209 // Camera roll
})
}
结果iOS 13:
<PHFetchResult: 0x280560960> count=14
<PHAssetCollection: 0x14de1b9d0> B93E78CF-FBE8-4791-9B63-009AC9F40FCE/L0/040, title:"Panoramas", subtitle:"(null)" assetCollectionType=2/201
<PHAssetCollection: 0x14de21470> FA7600A5-2B42-4C6F-AC50-B604810BC06B/L0/040, title:"Favorites", subtitle:"(null)" assetCollectionType=2/203
<PHAssetCollection: 0x14de06aa0> 4329C50B-EE1D-494A-8585-5FC1DBFE890F/L0/040, title:"Slo-mo", subtitle:"(null)" assetCollectionType=2/208
<PHAssetCollection: 0x14de0f910> C32B141D-3BCB-4525-8EAD-A24DEE904F60/L0/040, title:"Live Photos", subtitle:"(null)" assetCollectionType=2/213
<PHAssetCollection: 0x14de1aa90> 2355B0FA-6CDD-4B59-A089-5CA2CCD059DF/L0/040, title:"Videos", subtitle:"(null)" assetCollectionType=2/202
<PHAssetCollection: 0x14de1abd0> F71FE5C0-D5CD-4417-8666-F11C85240448/L0/040, title:"Animated", subtitle:"(null)" assetCollectionType=2/214
<PHAssetCollection: 0x14de10040> 1B2B6D54-1622-4953-87BD-7FF112D3F886/L0/040, title:"Selfies", subtitle:"(null)" assetCollectionType=2/210
<PHAssetCollection: 0x14de10180> B2D3ECEE-E0D0-44E9-94F6-F9C076B7E91A/L0/040, title:"Time-lapse", subtitle:"(null)" assetCollectionType=2/204
<PHAssetCollection: 0x14de102c0> CDBCF8A4-50ED-4709-809A-BFC2C3B8BFE7/L0/040, title:"Hidden", subtitle:"(null)" assetCollectionType=2/205
<PHAssetCollection: 0x14de10400> 776A0192-C323-4932-9328-50D9C7A364FE/L0/040, title:"Portrait", subtitle:"(null)" assetCollectionType=2/212
<PHAssetCollection: 0x14de10540> 46B7DFE0-F9EA-46DA-8C51-5570E3AF37AB/L0/040, title:"Bursts", subtitle:"(null)" assetCollectionType=2/207
<PHAssetCollection: 0x14de10680> 5EF48500-3FAA-415A-800C-C160CC8D1A19/L0/040, title:"Recents", subtitle:"(null)" assetCollectionType=2/209
<PHAssetCollection: 0x14de296c0> F28207C8-9B4F-44A8-9F5B-32E6C6169B6E/L0/040, title:"Long Exposure", subtitle:"(null)" assetCollectionType=2/215
<PHAssetCollection: 0x14de29800> 4426D307-05B1-42C5-9F9B-391EA25CDDA2/L0/040, title:"Screenshots", subtitle:"(null)" assetCollectionType=2/211
结果iOS 12
<PHFetchResult: 0x280c51a80> count=15
<PHAssetCollection: 0x1057046e0> 70B8F334-A376-4EFF-B92B-E3329F97F7B1/L0/040, title:"Recently Added", subtitle:"(null)" assetCollectionType=2/206
<PHAssetCollection: 0x105749e90> DA0DDAE1-1028-469D-B700-6F52F9F375B1/L0/040, title:"Portrait", subtitle:"(null)" assetCollectionType=2/212
<PHAssetCollection: 0x10574d320> 70B0A71A-08D2-4C3C-B96E-5380CAA83A36/L0/040, title:"Slo-mo", subtitle:"(null)" assetCollectionType=2/208
<PHAssetCollection: 0x10574d440> 99DB1706-09FB-4ADD-AAF9-46CC47AEAF49/L0/040, title:"Time-lapse", subtitle:"(null)" assetCollectionType=2/204
<PHAssetCollection: 0x10574d620> 91D9696D-E4CC-46E8-AABD-E6A90D06D954/L0/040, title:"Animated", subtitle:"(null)" assetCollectionType=2/214
<PHAssetCollection: 0x10574d740> 19FA3952-F1B0-469E-82C2-A983879322E2/L0/040, title:"Screenshots", subtitle:"(null)" assetCollectionType=2/211
<PHAssetCollection: 0x10574d860> D9D5099F-FA01-4903-B611-A3484ED53FDE/L0/040, title:"Favorites", subtitle:"(null)" assetCollectionType=2/203
<PHAssetCollection: 0x10574d980> 5A27E642-D6DD-4DFE-B90E-6BD17F5C73B6/L0/040, title:"Long Exposure", subtitle:"(null)" assetCollectionType=2/215
<PHAssetCollection: 0x10574daa0> 9C5D6211-B455-419A-BB2C-59AED1F76F46/L0/040, title:"Videos", subtitle:"(null)" assetCollectionType=2/202
<PHAssetCollection: 0x10574dbc0> 35802A7D-CD77-4B0A-BCE8-F10F784EE03A/L0/040, title:"Selfies", subtitle:"(null)" assetCollectionType=2/210
<PHAssetCollection: 0x10574dce0> DD650AAF-3E39-46AE-952F-484857514CD4/L0/040, title:"Live Photos", subtitle:"(null)" assetCollectionType=2/213
<PHAssetCollection: 0x10574de00> 5CFEE773-4485-4B7C-A9AF-9DF0FDAB90F4/L0/040, title:"Hidden", subtitle:"(null)" assetCollectionType=2/205
<PHAssetCollection: 0x10574df20> 3B453048-7296-4010-9E3A-0F812FC2B1FA/L0/040, title:"Panoramas", subtitle:"(null)" assetCollectionType=2/201
<PHAssetCollection: 0x10574e040> 7F229A8E-96DB-4ABD-97FD-70745E4E52D6/L0/040, title:"All Photos", subtitle:"(null)" assetCollectionType=2/209
<PHAssetCollection: 0x10574e160> 5A43BE12-37E6-4617-920E-8600C21D4B03/L0/040, title:"Bursts", subtitle:"(null)" assetCollectionType=2/207
我的问题是:相机胶卷(所有照片)相册现在在哪里?我怎么才能得到它?