Titanium JS:无法在TiSocial模块中使用存储在SQLite数据库中的图像(Titanium JS: cannot use an image stored in SQLite Datab

编程入门 行业动态 更新时间:2024-10-23 22:36:07
Titanium JS:无法在TiSocial模块中使用存储在SQLite数据库中的图像(Titanium JS: cannot use an image stored in SQLite Database in TiSocial module)

我的应用程序在本地SQLite数据库中有一堆存储为blob的图像。 这些图像是使用设备相机拍摄的。 我正在使用钛合金,因此使用.save()方法和合金模型保存图像。

我已经开始使用可以将图像发布到Twitter或Facebook的TiSocial模块 。 其中一个参数是image ,它必须是:

要共享的图像的本地/远程路径

我想要使​​用的图像被设置为ImageView上的图像属性。 ImageView图像设置如下: $.theImageView.image = args.the_image; ,其中args.image是从数据库集合中获取的图像blob。

我尝试将此图像blob设置为TiSocial模块初始化方法上的图像:

Social.activityView({ text: "Hello world! Take a look at this: " + args.name, image: args.the_image, removeIcons:"airdrop,print,copy,contact,camera" });

或者,我尝试使用ImageView上保存的图像,如下所示:

Social.activityView({ text: "Hello world! Take a look at this: " + args.name, image: $.theImageView.image, removeIcons:"airdrop,print,copy,contact,camera" });

但是这些都不起作用,并且Tweet或Facebook消息对话框中没有显示图像。 并且控制台中不会出现任何错误。

另一方面,如果我将image属性设置为保存在assets文件夹中的图像,那么它可以正常工作。 例如:

`image: "an_image.jpg"`

我尝试了下面评论中提到的解决方案,即将图像保存到Ti.FileSystem,然后从那里读取图像。 但是,这仍然无效。

My app has a bunch of images stored as blobs in the local SQLite Database. These images are taken with the device camera. I'm using Titanium Alloy, so the image was saved using the .save() method an Alloy Model.

I've started using the TiSocial module that can post an image to Twitter or Facebook. One its parameters is image and it has to be:

a local/remote path to an image you want to share

The image I want to use is set as the image property on an ImageView. The ImageView image is set like this: $.theImageView.image = args.the_image;, where args.image is the image blob, taken from the database collection.

I tried to take this image blob and set it as the image on the TiSocial module initialisation method:

Social.activityView({ text: "Hello world! Take a look at this: " + args.name, image: args.the_image, removeIcons:"airdrop,print,copy,contact,camera" });

Alternatively I tried to take use the image saved on the ImageView, like this:

Social.activityView({ text: "Hello world! Take a look at this: " + args.name, image: $.theImageView.image, removeIcons:"airdrop,print,copy,contact,camera" });

However neither of these worked, and no image appears in the Tweet or Facebook message dialogs. And no error appears in the console.

On the other hand, if I set the image property to an image saved in the assets folder, then it works just fine. For example:

`image: "an_image.jpg"`

I tried a solution mentioned in the comments below, which was to save the image to Ti.FileSystem, and then read the image from there. However, this still did not work.

最满意答案

您可以尝试以这种方式共享远程图像......

var largeImg = Ti.UI.createImageView({ width : Ti.UI.SIZE, height : 'auto', image :'http://www.google.com/doodle4google/images/splashes/featured.png' }); var imageGoogle =largeImg.toBlob(); // share image Social.activityView({ status : "Hello world! Take a look at this: ", image : imageGoogle, removeIcons:"airdrop,print,copy,contact,camera" });

I had some luck by saving the file to the Ti.Filesystem, and then later retrieving it and using the .getNativePath() method:

function getImage() { var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, args.alloy_id + '.jpg'); return f.read(); } var theImage = getImage(); Social.activityView({ text: "Just tried this beer called " + args.name, image: theImage.getNativePath(), removeIcons:"airdrop,print,copy,contact,camera" });

更多推荐

本文发布于:2023-04-29 03:13:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1334561.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据库中   模块   图像   TiSocial   JS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!