图像基于钛appcelerator视图中的base64

sda*_*pos 2 base64 titanium titanium-alloy

我想从SQLite中放一个图像,但下面的代码不起作用:

var imageView = Ti.UI.createImageView({
            image:services.fieldByName('image')
});
Run Code Online (Sandbox Code Playgroud)

Aar*_*ers 7

执行此操作以在保存之前将blob转换为字符串

var stringToSaveInDatabase = Ti.Utils.base64encode(thumbBlob).toString();
Run Code Online (Sandbox Code Playgroud)

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

var imageBlob = Ti.Utils.base64decode(stringRetrievedFromDatabase);
Ti.UI.createImageView({ image:imageBlob });
Run Code Online (Sandbox Code Playgroud)

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