在我的应用程序中,我拍照并使用ALAssetsLibrary将网址保存到它。此代码如下所示:如何将照片(或视频)从相机转换为NSData?
ALAssetsLibrary().writeImageToSavedPhotosAlbum(image.CGImage, orientation: ALAssetOrientation(rawValue: image.imageOrientation.rawValue)!,
completionBlock:{ (path:NSURL!, error:NSError!) -> Void in
if(error == nil){
path.save()
//.......
}
})
我需要将照片转换为NSData对象。那么如何根据IOS 9.0准则(我知道ALASsetsLibrary在IOS 9中不推荐使用)来替代此代码?我怎样才能将我的照片转换为NSData对象?
只需在您的块中使用此功能。 'UIImagePNGRepresentation(image)' –