1

我正在使用 swift PHPhotoLibrary 类将图像保存在照片库中。下面是我的代码:

PHPhotoLibrary.sharedPhotoLibrary().performChanges( {
        let assetCreation = PHAssetCreationRequest.creationRequestForAssetFromImage(self.photoView.image!)
        let imageData = UIImageJPEGRepresentation((self.photoView?.image)!,1)
        let option = PHAssetResourceCreationOptions()
        assetCreation.addResourceWithType(PHAssetResourceType.FullSizePhoto, data: imageData!, options: option)


    },
    completionHandler: {
            success, error in
        if success {
            print("save image success" )
        } else {
            print(error)
        }
    })

但我总是收到此错误消息: Optional(Error Domain=NSCocoaErrorDomain Code=-1 "(null)") 此错误由 else 行打印:"print(error)"

有谁知道问题是什么?

4

0 回答 0