【发布时间】:2015-11-02 13:10:59
【问题描述】:
我正在使用照片框架使用此代码在 iOS8 中获取相册列表,
如何重新排序 smartAlbums,所以我可以显示“最近添加”
let smartAlbums : PHFetchResult = PHAssetCollection.fetchAssetCollectionsWithType(PHAssetCollectionType.SmartAlbum, subtype: PHAssetCollectionSubtype.AlbumRegular, options: nil)
在 cellForRow 方法中
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let collection = smartAlbums[indexPath.row]
cell.textLabel?.text = collection.localizedTitle
return cell
}
let photofetchOpt:PHFetchOptions? = PHFetchOptions()
photofetchOpt?.sortDescriptors = [NSSortDescriptor(key:"localizedTitle", ascending: false)]
我在获取 AssetCollections 时尝试使用 PHFetchOptions,但对 smartAlbums 的顺序没有影响。
【问题讨论】:
标签: iphone swift ios8 swift2 xcode7