Ios 将字符串转换为图像问题

Ios 将字符串转换为图像问题,ios,base64,Ios,Base64,我正在呼叫一个web服务。有一个图像。这是一种字符串格式。如何将Base64字符串转换为图像 谢谢。在项目中添加Base64类 您可以使用以下方法进行编码: NSData* data = UIImageJPEGRepresentation(yourImage, 1.0f); [Base64 initialize]; NSString *strEncoded = [Base64 encode:data]; [Base64 initialize]; NSData* data = [Base64

我正在呼叫一个web服务。有一个图像。这是一种字符串格式。如何将Base64字符串转换为图像


谢谢。

在项目中添加Base64

您可以使用以下方法进行编码:

NSData* data = UIImageJPEGRepresentation(yourImage, 1.0f);
[Base64 initialize];
NSString *strEncoded = [Base64 encode:data];
[Base64 initialize]; 
NSData* data = [Base64 decode:strEncoded ];;
image.image = [UIImage imageWithData:data];
解码
使用:

NSData* data = UIImageJPEGRepresentation(yourImage, 1.0f);
[Base64 initialize];
NSString *strEncoded = [Base64 encode:data];
[Base64 initialize]; 
NSData* data = [Base64 decode:strEncoded ];;
image.image = [UIImage imageWithData:data];
查看此了解更多信息


您还可以参考

对base 64进行解码,然后将图像数据作为NSData获取。从NSData创建UIImage。该测验中的答案是什么。这不可能吗?