Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

imageview in tableviewrow crash

I have a fairly simple app setup. I have a table view, and I am loading a remote image (via URL) into an imageview that I add to the first row of the tableview:

var image_row = Ti.UI.createTableViewRow({height:'auto'});
    var item_image = Ti.UI.createImageView({
        url: 'http://mysiteurl.com/media/'+item.image_url,
        top: 5,
    bottom: 5,
        left: 'auto',
        right: 'auto',
        width: 280,
        height: 'auto'
    });
    image_row.height = 'auto';

    image_row.add(item_image);

    tableview.appendRow(image_row);

When I navigate to that particular tableview the first time, everything is fine. However, if I navigate away (back to previous view) and back again, I get this error message on the second load of that tableview:

* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of sections. The number of sections contained in the table view after the update (1) must be equal to the number of sections contained in the table view before the update (1), plus or minus the number of sections inserted or deleted (1 inserted, 0 deleted).'

Not sure if this is a Titanium thing with loading imageviews in tableviewrows. Anyone seen this before? Any help?

— asked May 13th 2010 by Ben Hornedo
  • crash
  • imageview
  • row
  • tableview
0 Comments

5 Answers

  • Same problem here.

    — answered June 23rd 2010 by David Riccitelli
    permalink
    0 Comments
  • same problem

    — answered August 6th 2010 by Ritesh Manchanda
    permalink
    0 Comments
  • Hi there,

    have you tried using a className in the TableviewRow object? I've found that using this greatly improves the performance and stability of images in TableViews.

    className string
    the class name of the table. each table view cell must have a unique class name if the cell layout is different. however, use the same name for rows that have the same structural layout (even if the content is different) to provide maximum rendering performance.

    So if you called your classname 'imagerowClass' your code would become

    var image_row = Ti.UI.createTableViewRow({
        height:'auto', 
        className:'imagerowClass'});
        var item_image = Ti.UI.createImageView({
            url: 'http://mysiteurl.com/media/'+item.image_url,
            top: 5,
        bottom: 5,
            left: 'auto',
            right: 'auto',
            width: 280,
            height: 'auto'
        });
    
        image_row.add(item_image);
        tableview.appendRow(image_row);
    

    Note that I've dropped the second declaration of image_row.height as well. You had it both in the var image_row line and further down in the code.

    Hope this helps.

    — answered August 6th 2010 by Gregor Munro
    permalink
    0 Comments
  • Hi, I also have the same problem in my project. However, I have found that in the demo program "KitchenSink" there is a few examples of having imageview inside tableview. I have copied the code over to my project and it still crashes. Any ideas on whether KitchenSink did some other setting before the tableview was loaded? Any setting in that project that could have prevented the crash?

    Thanks

    — answered February 22nd 2011 by Eric Ou
    permalink
    0 Comments
  • Sorry to say that this bug still exists in the latest 1.7 ci build… :(

    — answered May 3rd 2011 by Justin Toth
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.