我有一个 UIImagePickerController,我想将选定的图像保存到我的应用程序中。我可以通过获取当前的 UIImage 并保存它(通过创建文件)来轻松做到这一点,但我更愿意直接将文件从库复制到我的文件夹中。
现在我有了所选图像的 URL:UIImagePickerControllerReferenceURL,它返回特定的模式“assets-library”。我尝试将图像从此类 URL 复制到路径,但没有成功。
我想做的事情有成功的方法吗?
谢谢 !
你可以通过两种方式做到这一点
第一种方式: Using uiimagePickerController didFinishPickingMediaWithInfo
代表
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *selectedImage = [info valueForKey:UIImagePickerControllerOriginalImage];
//save selectedImage to document directory
}
第二种方式: Using ALAssetLibrary
.
为此,您必须保存ALAsset URL
并使用检索图像ALAssetLibrary
,请参考我的详细回答 https://stackoverflow.com/questions/13508535/add-uiimageview-into-uiscrollview-inside-block-with-alasset/13508841#13508841.只要把你的ALAsset url
代替asseturl
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)