无法在iOS应用程序中显示BLOB图像

时间:2014-06-12 14:45:11

标签: ios json uiimageview blob nsdata

我试图在我的iOS应用中显示BLOB图像(使用Json从Web服务器获取),但是当我运行我的应用程序时,我得到一个空的UIimageView,这是我的代码:

NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:encodedUrl]];
NSData *profileImage1 = [[NSData alloc] initWithBytes:[dataURL bytes] length:[dataURL length]];
UIImage *profileImage2 = [UIImage imageWithData:profileImage1];
[profilImage setImage:profileImage2];

如何解决此问题?

1 个答案:

答案 0 :(得分:0)

[UIImage imageWithData:data]仅解析JPEG,PNG等已知图像文件格式(decomentation中的完整信息)。 UIImage不支持传递blob。您需要进行一些解码才能将数据用于UIImage。您可以使用GMTBase.64进行数据编码和解码。阅读文档和其他帖子,您将了解如何更改代码。

希望这有帮助。