我正在制作一个使用AVFoundation拍照的应用程序,我想将它们保存到自定义相册中,然后我可以在我的应用中查询和显示.(除非用户想要,否则我宁愿不在普通照片卷中使用它们)我无法在Swift中找到任何显示如何执行此操作的内容......或者根本没有.有没有不同的方式我应该这样做?
我在SO上找到了这个例子,但它对我没有意义,我无法让它工作.
func savePhoto() {
var albumFound : Bool = false
var assetCollection: PHAssetCollection!
var photosAsset: PHFetchResult!
var assetThumbnailSize:CGSize!
// Create the album if does not exist (in viewDidLoad)
if let first_Obj:AnyObject = collection.firstObject{
//found the album
self.albumFound = true
self.assetCollection = collection.firstObject as PHAssetCollection
}else{
//Album placeholder for the asset collection, used to reference collection in completion handler
var albumPlaceholder:PHObjectPlaceholder!
//create the folder
NSLog("\nFolder \"%@\" does not exist\nCreating now...", albumName)
PHPhotoLibrary.sharedPhotoLibrary().performChanges({
let request = PHAssetCollectionChangeRequest.creationRequestForAssetCollectionWithTitle(albumName)
albumPlaceholder = request.placeholderForCreatedAssetCollection
}, …Run Code Online (Sandbox Code Playgroud)