objective-c - 从 NSArray 以字节形式检索 UIImage - iOS

标签 objective-c ios xcode uiimage nsarray

我有一个数组,其中包含一组字节形式的 UIImage。 -- 我的合作伙伴将 UIImage 保存在数据库中,他创建了一个数组来检索数据-- 我创建这个数组是为了从数组中检索数据:

for (NSDictionary *row in arr){
NSData *imgData = [row objectForKey:@"ImageFile"];

当我将它放入 NSLog 时,它给出了正确的数据。但是,当我尝试使用此显示图像时:

UIImage *imgDis = [UIImage imageWithData:imgData];

它给我一个错误提示 [__NSCFString bytes]: unrecognized selector sent to instance..

老实说,我不知道该怎么做,所以如果有人能帮助我,我将不胜感激。

最佳答案

正如@Safecase 在评论中所说,我决定保存图像路径而不是图像本身。这样,我可以只使用 UIImage imageWithContentsOfFile:imageFilePath 来显示图像。感谢您的帮助!

关于objective-c - 从 NSArray 以字节形式检索 UIImage - iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11099766/

相关文章:

ios - 专为 Iphone 6 设计的调整大小应用程序可在 iphone 5s 中正确缩放

ios - 创建通用应用程序的原则

iphone - 在 Xcode Storyboard 中查看自定义文本

xcode - 设置 Xcode 以使用 Arduino

ios - 是否有必要在钥匙串(keychain)中为访问组命名

ios - Xcode 7 Magical Record 单元测试失败

ios - swift ios : different errors for similar data . 。很奇怪

objective-c - 使用 ios sdk 3.0 的事件回复

iphone - 对象的委托(delegate)将其自身传递给委托(delegate)

ios - 同一项目中另一个文件夹中的访问类 (Xcode)