Titanium Community Questions & Answer Archive

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

tableView + imageView Performance Issue

I'm running into an interesting issue when using a tableview and imageview for approx. 140 records.

The tableview loads, but does not seem to scroll. If I remove the imageview everything works as expected.

I believe this might be a memory issue since I'm running this on an iPhone 3G. Has anyone experienced something similar? There isn't a ton of records, approx. 140 and the images are 1KB each.

~~~

function addRow(myInfo,imgUrl){

var row = Ti.UI.createTableViewRow();
row.height  =50;
row.className = 'datarow';
row.msgInfo = myInfo;

var lbl1 = Ti.UI.createLabel({
    text:myInfo,
    height:30,
    width:'auto',
    color:'#000000',
    font:{fontSize:18},
    textAlign:'left',
    left:50
});

row.filter = lbl1.text;
row.add(lbl1);

var img1 = Ti.UI.createImageView({url:imgUrl,width:30,height:30,left:10});
row.add(img1);
data.push(row);

};

var rows = win.appDbConn.execute('SELECT MY_INFO, IMG_URL,BACTIVE FROM MY_TBL');
if(rows.getRowCount()>0){
while (rows.isValidRow()){
addRow(rows.field(0),rows.field(1));
rows.next();
}
rows.close();

— asked May 6th 2010 by Ben Bahrenburg
  • imageview
  • iphone
  • tableview
0 Comments

6 Answers

  • Accepted Answer

    Do you need to add rows? I'm using 50 rows with rounded image corners with a small slowness on scrolling using setData
    On an iPod 2nd gen.

    — answered May 6th 2010 by Dan Tamas
    permalink
    0 Comments
  • Is that addRow function exactly the one you're using in your app? I ask because one thing I found that kills scrolling performance is to use a borderRadius with images, so if you're using that try removing it and see if it makes any difference.

    — answered May 6th 2010 by Dan Giulvezan
    permalink
    2 Comments
    • Wow, removing borderRadius made a huge improvement in performance. Thanks Dan!

      — commented August 9th 2013 by B S
    • Ditto. I found that compositing my images together to mimic a border radius works much better than using border radius. Border Radius made the table scrolling much more jumpy / jerky.

      — commented February 14th 2014 by david brewer
  • Is the image different for each row? You might try making className unique per row in that case. On Android scrolling doesn't always change the images correctly unless className is unique.

    — answered May 6th 2010 by Vinh Bui
    permalink
    0 Comments
  • Hey Ben,

    If you reduce the number of rows you display to 50 does it make any difference? Not suggesting that as a fix, just curious if it let's the scroll work. I've done something similar in the past but never with more than 50 or so rows and scrolling was fine.

    Your code looks fine and as I understand the className property you're using it correctly (rows with the same style should have the same className on iPhone, maybe different on Android?).

    Also, which version of the mobile SDK are you using?

    — answered May 6th 2010 by Dan Giulvezan
    permalink
    0 Comments
  • Hi Dan,

    I'm using the iPhone SDK 3.1 and the latest Titanium Mobile SDK 1.2.

    It works with 10 records, although alittle slow. But with 50+ it loads but no scrolling. I haven't tried renaming the classname yet so not sure if that fixes the issue.

    — answered May 6th 2010 by Ben Bahrenburg
    permalink
    0 Comments
  • @Bryan hopefully that className image view thing is fixed. We put a couple of patches in yesterday. Will be in 1.3.0.

    — answered May 6th 2010 by Don Thorp
    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.