【问题标题】:Image based on base64 in titanium appcelerator view钛应用加速器视图中基于 base64 的图像
【发布时间】:2013-07-18 16:15:50
【问题描述】:

我想从 SQLite 放一张图片,但下面的代码不起作用:

var imageView = Ti.UI.createImageView({
            image:services.fieldByName('image')
});

【问题讨论】:

    标签: titanium base64 titanium-alloy


    【解决方案1】:

    在保存之前将 blob 转换为字符串

    var stringToSaveInDatabase = Ti.Utils.base64encode(thumbBlob).toString();
    

    当您准备好将其添加到视图中时,请执行此操作

    var imageBlob = Ti.Utils.base64decode(stringRetrievedFromDatabase);
    Ti.UI.createImageView({ image:imageBlob });
    

    http://docs.appcelerator.com/titanium/3.0/#!/api/Titanium.Utils-method-base64encode

    【讨论】:

    • 感谢您的回答我的问题是我从 API 获取数据,该 api 将图像存储在 MYSQL 数据库中,
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-01
    • 1970-01-01
    相关资源
    最近更新 更多