【问题标题】:Mysql blob image display in UiImage swift 3UiImage swift 3中的Mysql blob图像显示
【发布时间】:2016-08-30 15:39:57
【问题描述】:

我有一个将图像存储为 blob 的数据库,并希望将它们显示在 UiImage 中。我可以将数据作为 JSON 提要输入我的应用程序,并且可以按如下方式获取图像数据(通过打印)

[["image": <UIImage: 0x14ea397b0> size {750, 750} orientation 0 scale 1.000000]]

我不知道如何将这些数据转换回故事板上的 UIImage

【问题讨论】:

    标签: ios mysql uiimageview blob swift3


    【解决方案1】:

    假设您将 blob 数据作为来自 db 的字符串。您可以将其转换为如下所示的图像。

    let imageBytes = "" // blob data
    DispatchQueue.main.async {
        if let imgData = imageBytes.dataUsingEncoding(NSUTF8StringEncoding){
            self.imageView.image = UIImage(data: imgData)
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2016-12-16
      • 1970-01-01
      • 2011-07-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多