gpt4 book ai didi

ios - 如何将从UIImagePickerViewController拾取的图像的路径保存到sqlite数据库并在以后访问? ios

转载 作者:行者123 更新时间:2023-12-01 19:14:12 26 4
gpt4 key购买 nike

我需要保存从服务器选择的图像的路径,以后再访问该路径以在用户单击数据库检索时显示该图像。

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSString *urlPath = [info objectForKey:@"UIImagePickerControllerReferenceURL"]absoluteString];
}

并将其保存到数据库。

它另存为 asset-library://asset/asset.JPG?id = E1136225-97DE-4BF4-A864-67E33D60737A&ext = JPG

然后我想导入到 Imageview
 UIImageView *iv = [[UIImageView alloc]init];
iv.image = [UIimage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imagepath]]];

但这不起作用

最佳答案

使用ALAssetsLibrary类的assetForURL:resultBlock:failureBlock:方法通过URL检索图像。
还有更多信息:http://developer.apple.com/library/ios/#documentation/AssetsLibrary/Reference/ALAssetsLibrary_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40009722

UPD:

ALAssetsLibrary *lib = [[ALAssetsLibrary alloc] init];
[lib assetForURL: url resultBlock: ^(ALAsset *asset) {
ALAssetRepresentation *r = [asset defaultRepresentation];
self.imgView.image = [UIImage imageWithCGImage: r.fullResolutionImage];
}
failureBlock: nil];
url在哪里是您的缓存URL

关于ios - 如何将从UIImagePickerViewController拾取的图像的路径保存到sqlite数据库并在以后访问? ios,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14378599/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com