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();
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. -
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.
-
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.
-
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?
-
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.
-
@Bryan hopefully that className image view thing is fixed. We put a couple of patches in yesterday. Will be in 1.3.0.