UIImage to base64字符串编码 [英] UIImage to base64 String Encoding

查看:195
本文介绍了UIImage to base64字符串编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将 UIimage 转换为base64编码的字符串?我找不到任何有详细说明的例子或代码。

How to convert UIimage to base64 encoded string? I couldn't find any examples or codes with detailed regarding.

推荐答案

我想知道你为什么不找到你的问题,因为它是一个非常古老的问题&可以在这里这里

I wonder why didn't you find your question because it's a very old question & can be found here and here.

无论如何,
你需要首先将 NSData 类别添加到您的项目中,这些类别可从此处获得 -

Anyways, You need to first add NSData categories to your project which are available from here -

标题 implementation
然后将 UIImage 对象转换为 NSData 以下方式:

header and implementation Then convert your UIImage object into NSData the following way:

NSData *imageData = UIImageJPEGRepresentation(image, 1.0);

然后应用 Base64 编码将其转换为 base64 编码字符串:

And then apply Base64 encoding to convert it into a base64 encoded string:

NSString *encodedString = [imageData base64Encoding];

这篇关于UIImage to base64字符串编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆