我有一個SplitviewController,它顯示圖像列表。點擊時,它將顯示在主屏幕上,我想在其下面顯示該圖像的元數據。 我的圖像是由一個自己寫的類來管理的,它們將它們存儲爲UIImages。 我得到的只是嵌入作爲的ressource文件,並通過iOS通過Splitview Controller加載的圖像元數據
NSString* pathToImageFile = [[NSBundle mainBundle] pathForResource:imageName
ofType:@"jpg"];
UIImage* img = [UIImage imageWithContentsOfFile:pathToImageFile];
用戶已經通過imagePicker將圖片添加到這個列表或者出庫或相機的選擇加載4張實例圖片。
現在我需要一種方法來訪問圖像的元數據,當用戶選擇表中的一行。我知道UIImage不包含任何元數據,但有沒有辦法訪問底層jpg並從中檢索元數據?這裏的主要問題是我有三個不同的圖像來源(app directoy,相冊,照相機)。 或者我需要重寫我的圖片商店類,它必須跟蹤我的元數據或我的網址以及圖片嗎? 以下是我的didSelectRow方法,我想添加一個方法來檢索所選圖像的元數據。
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UIImage *img = [[[ImageStore sharedStore] getAllImages] objectAtIndex:[indexPath row]];
self.detailViewController.detailItem = img;
}
感謝您的幫助!