ios - 我的应用程序中仅显示一张表情符号图像

标签 ios swift

我正在构建聊天应用程序,需要发送和接收表情符号图像。我使用以下代码来发布数据:

 let myUrl = NSURL(string: "http://test.php")  
 let request = NSMutableURLRequest(URL:myUrl!)
 request.HTTPMethod = "POST"    
 let postString = " shareImageMessage=\(message)"
 request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding)

我可以在调试区域中看到带有表情符号的消息,如下所示:

Debug area output

但mysql数据库中仅显示以下图像:

mysql screenshot

以及来自 php 脚本的以下代码:

$shareImageMessage = $_POST["shareImageMessage"];

我不明白为什么只有一种图像传输。

最佳答案

要在同一 URL 中发送多个表情符号,只需将发送到服务器的字符串转换为 Base64,然后在数据库的另一端对其进行解码即可。要将字符串编码和解码为 base64,您可以检查此 Convert between UIImage and Base64 string 。 :)

关于ios - 我的应用程序中仅显示一张表情符号图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36543901/

相关文章:

应用程序 openURL 委托(delegate)后未调用 iOS Google+ SignIn finishedWithAuth

iphone - 为 MKMapView 设置缩放级别

ios - Failed to parse app's Info.plist appcelerator studio 错误

ios - iOS:处理nsstring

swift - 谷歌云物联网 : How to connect to MQTT bridge from iOS applications written in Swift?

ios - 创建自己的关卡编辑器的最佳方式

ios - 在可移动的 ImageView 上显示 View

ios - 使用引用条码字符串生成 UPC-A 条码图像

swift - 在 Swift 中添加日期类型和 Int 类型?

ios 自定义 UIButton 缩放 setImage 向下不起作用