0
Ich habe eine SammlungView in meinem Projekt ausgeführt, die iPhone-Fotobibliothek mithilfe von Fotos Rahmen erfolgreich abruft.Ich versuche, die FotosammlungView vom letzten Foto.Ich benutze den folgenden Code ....Fotos Rahmen aufsteigend in Swift
func getAllPhotosInfo() {
photoAssets = []
let options = PHFetchOptions()
options.sortDescriptors = [
NSSortDescriptor(key: "creationDate", ascending: false)
]
let assets: PHFetchResult = PHAsset.fetchAssetsWithMediaType(.Image, options: options)
assets.enumerateObjectsUsingBlock { (asset, index, stop) -> Void in
self.photoAssets.append(asset as! PHAsset)
}
print(photoAssets)
}
// PHAsset zur Bildumwandlung
import UIKit
import Photos
class CollectionViewCell: UICollectionViewCell {
var imageManager: PHImageManager?
@IBOutlet weak var photoImageView: UIImageView!
var imageAsset: PHAsset? {
didSet {
self.imageManager?.requestImageForAsset(self.imageAsset!, targetSize: CGSize(width: 320, height: 320), contentMode: .AspectFill, options: nil) { image, info in
self.photoImageView.image = image
}
}
}
}
So weit so gut ... was scheint das Problem zu sein? – luk2302
@ luk2302 Ich führe die Funktion getAllPhotosInfo() innerhalb der ViewDidLoad, aber nicht die Sammlungsansicht aufsteigend ... – Joe