简体   繁体   English

如何从iPhone中的资产URL访问图像?

[英]How to access image from Asset URL in iPhone?

I am getting asset URL from NSURL* localUrl = (NSURL *)[info valueForKey:UIImagePickerControllerReferenceURL]; 我正在从NSURL* localUrl = (NSURL *)[info valueForKey:UIImagePickerControllerReferenceURL];获取资产URL NSURL* localUrl = (NSURL *)[info valueForKey:UIImagePickerControllerReferenceURL]; and I saved it in a local database. 然后将其保存在本地数据库中。 And at the time of retrieving I have got an string and I have convert it into NSURL through NSURL *url1 = [NSURL URLWithString:image_path]; 并且在检索时,我有一个字符串,并且已通过NSURL *url1 = [NSURL URLWithString:image_path];将其转换为NSURL *url1 = [NSURL URLWithString:image_path]; but when I get NSData from this URL through NSData *myData = [NSData dataWithContentsOfURL:url1]; 但是当我通过NSData从该URL获取NSData NSData *myData = [NSData dataWithContentsOfURL:url1]; it return NULL. 它返回NULL。 Can anyone help me to get NSData and convert it into image. 谁能帮我获得NSData并将其转换为图像。

You can not convert it direct. 您不能直接转换。 You will have to use ALAsset Block . 您将必须使用ALAsset Block Here is the complete description for same thing. 这是同一件事的完整描述。

display image from URL retrieved from ALAsset in iPhone 从iPhone中的ALAsset检索的URL显示图像

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM