Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9984] iOS: imageView error event not working on local files

GitHub Issuen/a
TypeBug
PriorityLow
StatusReopened
ResolutionUnresolved
Affected Version/sRelease 3.1.0
Fix Version/sn/a
ComponentsiOS
Labelsapi
ReporterHazem Khaled
AssigneeUnknown
Created2012-06-07T09:52:48.000+0000
Updated2018-02-28T20:03:31.000+0000

Description

Problem

ImageView error event not working with local files. If the image is remote image file the error event it will be executed accordingly.

Tested on

iOS simulator 4.3 & 5.1

Repro sequence

Titanium.UI.setBackgroundColor('#000');
var win1 = Titanium.UI.createWindow({  
    title:'Tab 1',
    backgroundColor:'#fff'
});
var label1 = Titanium.UI.createLabel({
    color:'#999',
    text:'I am Window 1',
    font:{fontSize:20,fontFamily:'Helvetica Neue'},
    textAlign:'center',
    width:'auto'
});
  
win1.add(label1);
win1.open();
  
var img = Ti.UI.createImageView({
   // First run.- Attempting to load a remote image file
   image:'http://files.daddyhunt.com/sites/default/files/imagecache/mangrid-212/photos/z/z/z/277606/Photo_on_2010-09-14_at_13.14_3.jpg'
   
   // Second run.- Attempting to load a local image file
   //image: 'KS_na_ui.png' 
});
win1.add(img);
img.addEventListener('error', function(e){
    label1.text = e.image + "image loading properly got an error!";
    img.image = 'KS_nav_ui.png';//loading alternative image
});

Comments

  1. Eduardo Gomez 2012-06-11

    @Hazem Khaled Can you paste logs from 1.8.2 & 2.x SDKs here please? Furthermore, what are the iOS versions and devices/simulators that this was tested on?
  2. Eduardo Gomez 2012-06-14

    Closing due to inactivity.
  3. Hazem Khaled 2012-06-16

    worked with me on OS 4.2 with any SDK, but not work OS 5.0 2.0.2 OS 5.0 log
       [INFO] One moment, building ...
       [INFO] Detected third-party module: tibar/0.4.2
       [INFO] Detected third-party module: tibar/0.4.2
       [INFO] Titanium SDK version: 2.0.2 (05/30/12 10:21 2ff31a3)
       [INFO] iPhone Device family: iphone
       [INFO] iPhone SDK version: 5.0
       [INFO] iPhone simulated device: iphone
       [INFO] Compiling localization files
       [INFO] Launching application in Simulator
       [INFO] Launched application in Simulator (8.73 seconds)
       [INFO] Application started
       [INFO] eshtery/0.99 (2.0.2.GA.2ff31a3)
       [INFO] [object TibarModule] loaded
       [WARN] [object TiUILabel] has an auto height value of 0, meaning this view may not be visible.
       [WARN] [object TiUILabel] has an auto width value of 0, meaning this view may not be visible.
       [WARN] [object TiUILabel] has an auto height value of 0, meaning this view may not be visible.
       [WARN] [object TiUILabel] has an auto height value of 0, meaning this view may not be visible.
       [WARN] [object TiUILabel] has an auto width value of 0, meaning this view may not be visible.
       [WARN] [object TiUILabel] has an auto height value of 0, meaning this view may not be visible.
       [WARN] [object TiUILabel] has an auto width value of 0, meaning this view may not be visible.
       [WARN] [object TiUILabel] has an auto height value of 0, meaning this view may not be visible.
       [WARN] [object TiUILabel] has an auto width value of 0, meaning this view may not be visible.
       [WARN] [object TiUILabel] has an auto height value of 0, meaning this view may not be visible.
       [WARN] [object TiUILabel] has an auto width value of 0, meaning this view may not be visible.
       [WARN] [object TiUILabel] has an auto height value of 0, meaning this view may not be visible.
       [WARN] [object TiUILabel] has an auto width value of 0, meaning this view may not be visible.
       [WARN] [object TiUILabel] has an auto height value of 0, meaning this view may not be visible.
       [WARN] [object TiUILabel] has an auto width value of 0, meaning this view may not be visible.
       [WARN] [object TiUILabel] has an auto height value of 0, meaning this view may not be visible.
       [WARN] [object TiUILabel] has an auto height value of 0, meaning this view may not be visible.
       [WARN] [object TiUILabel] has an auto height value of 0, meaning this view may not be visible.
       [WARN] [object TiUILabel] has an auto height value of 0, meaning this view may not be visible.
       [WARN] [object TiUILabel] has an auto height value of 0, meaning this view may not be visible.
       [WARN] [object TiUILabel] has an auto height value of 0, meaning this view may not be visible.
       [WARN] [object TiUILabel] has an auto height value of 0, meaning this view may not be visible.
       [WARN] [object TiUILabel] has an auto height value of 0, meaning this view may not be visible.
       [WARN] [object TiUILabel] has an auto height value of 0, meaning this view may not be visible.
       [WARN] [object TiUILabel] has an auto height value of 0, meaning this view may not be visible.
       [WARN] [object TiUILabel] has an auto height value of 0, meaning this view may not be visible.
       
    1.8
       
       [INFO] One moment, building ...
       [INFO] Detected third-party module: tibar/0.4.2
       [INFO] Detected third-party module: tibar/0.4.2
       [INFO] Titanium SDK version: 1.8.2 (02/23/12 17:46 59b3a90)
       [INFO] iPhone Device family: iphone
       [INFO] iPhone SDK version: 5.0
       [INFO] iPhone simulated device: iphone
       [INFO] Performing full rebuild. This will take a little bit. Hold tight...
       [INFO] Performing clean build
       [INFO] Compiling localization files
       [INFO] Launching application in Simulator
       [INFO] Launched application in Simulator (68.93 seconds)
       [INFO] Found 5.0 patch installed
       [INFO] Application started
       [INFO] eshtery/0.99 (1.8.2.59b3a90)
       [INFO] [object TibarModule] loaded
       
    Thanks
  4. Eduardo Gomez 2012-06-27

    Couldn't reproduce the issue as per sample you provided us. Furthermore, if I run code below starting from 1.8.2 to 2.1.0 CI SDKs will see the same output/behavior. - app.js
       Titanium.UI.setBackgroundColor('#000');
       var win1 = Titanium.UI.createWindow({  
           title:'Tab 1',
           backgroundColor:'#fff'
       });
       var label1 = Titanium.UI.createLabel({
           color:'#999',
           text:'I am Window 1',
           font:{fontSize:20,fontFamily:'Helvetica Neue'},
           textAlign:'center',
           width:'auto'
       });
        
       win1.add(label1);
       win1.open();
        
       var img = Ti.UI.createImageView({
       //  image:'http://someurl.com/someimage.png'
           image:'http://files.daddyhunt.com/sites/default/files/imagecache/mangrid-212/photos/z/z/z/277606/Photo_on_2010-09-14_at_13.14_3.jpg'
       });
       win1.add(img);
       img.addEventListener('error', function(e){
           label1.text = e.image + "image loading properly got an error";
           img.image = 'KS_nav_ui.png';
       });
       
  5. Hazem Khaled 2012-07-16

    after more check with 2.0 & 2.1 it don't work on error working only fired if http link get error, but if wrong local file it don't work (not working)
       var img = Ti.UI.createImageView({
           image : 'localfile.png'
       });
       
       img.addEventListener('error', function () {
          alert('Yahooo'); 
       });
       
    (working)
       var img = Ti.UI.createImageView({
           image : 'http://domain.com/remotefile.png'
       });
       
       img.addEventListener('error', function () {
          alert('Yahooo'); 
       });
       
  6. Eduardo Gomez 2012-07-16

    Moving to Titanium Mobile project to dig into it. Added the labels, updated the test case and issue description.
  7. Hazem Khaled 2012-07-17

    imgaeView have events like (load & error), they will not fired with local files, only fired with remote files working
       var img = Ti.UI.createImageView({
           image : 'http://domain.com/remoteFile.png'
       });
       
       img.addEventListener('error', function () {
          alert('Yahooo'); 
       });
       
       img.addEventListener('load', function () {
          alert('Yahooo'); 
       });
       
    not working
       var img = Ti.UI.createImageView({
           image : 'localFile.png'
       });
       
       img.addEventListener('error', function () {
          alert('Yahooo'); 
       });
       
       img.addEventListener('load', function () {
          alert('Yahooo'); 
       });
       
    only working with local files on Android when send it as blob data the solution (Android only) (load event only)
       var img = Ti.UI.createImageView({
           image : Ti.Filesystem.getFile(Ti.Filesystem.getApplicationDataDirectory(), 'KS_nav_views.png')
       });
       
       img.addEventListener('load', function () {
          alert('Yahooo'); 
       });
       
    Thanks
  8. jithinpv 2013-05-03

    issue reproduces Tested with Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 iOS iPhone Simulator: iOS SDK version: 6.0

JSON Source