Titanium ImageView wont display images?

本秂侑毒 提交于 2019-12-20 05:38:09

问题


I created an image directory in my projects in the UI folder to place my images. So the full path is currently Resources/UI/Images. When i create an image view it wont display the images. I tried different options, even a web image but nothing works?

var self = Ti.UI.createView({
    backgroundColor:'white'
});

var imgv = Titanium.UI.createImageView({url:"http://upload.wikimedia.org/wikipedia/commons/thumb/1/1a/Volkswagen_Logo.png/600px-Volkswagen_Logo.png"});
self.add(imgv);

var imgv = Titanium.UI.createImageView({url:"../images/sb02.jpg"});
self.add(imgv);

var imgv = Titanium.UI.createImageView({url:"Resources/ui/images/sb03.jpg"});
self.add(imgv);

回答1:


There is an error in your code. There is no url property for ImageView control. You should use image property. Try the following code

var imgv = Titanium.UI.createImageView({
                 image:"../images/sb02.jpg"
           });
self.add(imgv);



回答2:


To answer my question thanks to Anand for the tips:

  1. Images should be placed in the Resources dir
  2. Afterwards reference them just by /folder/image.jpg in my case /images/sb1.jpg


来源:https://stackoverflow.com/questions/17806846/titanium-imageview-wont-display-images

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!