简体   繁体   English

来自Splitview Controller加载的图像的iOS元数据

[英]iOS Metadata from images loaded by Splitview Controller

I have a SplitviewController that displays a list of images. 我有一个显示图像列表的SplitviewController。 When one is clicked it will be shown on the main screen and I want to display the metadata of this image below it. 当单击一个时,它将显示在主屏幕上,我想在其下方显示该图像的元数据。 My images are managed by a self written class that stores them as UIImages. 我的图像由一个自写的类管理,该类将它们存储为UIImages。 I got 4 example pictures that are just embedded as Ressource files and loaded via 我得到了4个示例图片,这些图片只是作为Ressource文件嵌入并通过

NSString* pathToImageFile = [[NSBundle mainBundle] pathForResource:imageName
                                                                ofType:@"jpg"];
UIImage* img = [UIImage imageWithContentsOfFile:pathToImageFile];

The User has the option to add pictures to this list via imagePicker either out of the library or the camera. 用户可以选择通过imagePicker将图片添加到该列表中,而不在图库或相机中。

Now I need a way to access the metadata of the images when the user chooses a row in the table. 现在,当用户在表中选择一行时,我需要一种访问图像元数据的方法。 I know that UIImages don't carry any metadata, but is there a way to access the underlying jpg and retrieve metadata from there? 我知道UIImages不包含任何元数据,但是有没有办法访问底层的jpg并从那里检索元数据? The main problem hereby would be that I have three different sources for the images (app directoy, photo album, camera). 因此,主要问题是我有三种不同的图像来源(应用程序直接,相册,相机)。 Or do I need to rewrite my image store class that it has to keep track of my metadata or my URLs as well as the images? 还是我需要重写必须跟踪我的元数据或URL以及图像的图像存储类? The following is my didSelectRow method where I want to add a method to retrieve metadata of the selected image. 以下是我的didSelectRow方法,其中我想添加一种方法来检索所选图像的元数据。

- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
     UIImage *img = [[[ImageStore sharedStore] getAllImages] objectAtIndex:[indexPath row]];
     self.detailViewController.detailItem = img;
}

Thanks for your help! 谢谢你的帮助!

If it's in the app directory you can read the file directly. 如果在应用目录中,则可以直接读取文件。 There is code here which will get the metadata using CGImageSource . 这里有代码,将使用CGImageSource获取元数据。

http://blog.depicus.com/index.php/2011/05/07/getting-exif-data-from-images-on-ios/ http://blog.depicus.com/index.php/2011/05/07/getting-exif-data-from-images-on-ios/

The photo library you get using ALAssetLibrary . 您使用ALAssetLibrary获得的照片库。 Eventually you will drill down to an ALAssetRepresentation , which has a metadata property. 最终,您将深入到具有元数据属性的ALAssetRepresentation

For a camera picture, to be honest I'm not entirely sure how you can do that without writing it to disk (photo library or application directory) first. 老实说,对于相机图片,我不完全确定如果不先将其写入磁盘(图片库或应用程序目录)怎么办。

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

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