imageView load event does not fire after image property is changed
Hi,
I am trying to display a loading throbber until all of the images are loaded on a particular screen. The image views are created with empty 'image' properties, and this is filled in later with a URL. The 'load' event is not firing when the remote image is loaded. This Post implies that the load event only fires on images where the image property has not been updated. Is this the case? Do I need to dynamically create the imageViews each time? I load different images to the same view periodically, so that would be kinda messy. Any ideas?
Relevant code (pulled from multiple places):
var imageView = Titanium.UI.createImageView({
width:100,
top:5,
left:30,
borderColor:'#999',
borderWidth:1
});
imageView.addEventListener('load', function() {imageLoaded();});
//^^^ this never fires^^^
imageView.image = "http://the.image.url";
Thanks for all your help.
4 Answers
-
On Android the load event doesn't fire at all. There is a bug. (more details here: android load event bug
On iPhone if the imageView has touchEnabled set to false, then the load event doesn't fire. (more details here:
iphone imageView load event bug -
i m having the same problem I think
http://developer.appcelerator.com/question/120733/splash-screen-image-load-question -
i use xhr to load the url manually, and set the image during onLoad. kitchen sink's xhr_binary.js illustrated this very well.
-
it might be completely irrelevant but try to change your syntax, try to use this:
imageView.addEventListener('load', imageLoaded);
ofc i assume that you got defined imageLoaded function in the same scope:
function imageLoaded(e) { … }