Titanium Community Questions & Answer Archive

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

Slow loading of a tableview when loading more than 200 rows from pre-packed DB (on Iphone)

Hi All,

I have spend a few days on this issue and I hope someone might be able to help.

The problem that I am having is that its very slow to load my data when I try and load a tableview with more than 200 rows from my custom sqlite db. (on Iphone)

I am only loading a name, and an Image. In the Simulator it loads fine, but when I publish my app and test it on my Iphone the window opens, and there is 20+ seconds before the tableview shows.

<script src='http://pastie.org/871807.js'></script>

I tried several things such as reducing the styling of my tableview, before it was quite nice and fancy. I had no luck and I cannot expect the USER to wait 20 seconds before loading the view.

I did change it to inline coding and it was alot faster.
<script src='http://pastie.org/871809.js'></script>

Even with 1000 rows it was loading in 5 seconds which is not amazing but will suffice.

So my question is:

1 - How can I improve the speed on a pre-packed database?
2 - If that cannot be possible, how can a show a ActivityIndicator before the tableview is rendered to the screen.

Thank you in advance,
Daniel Hollis

— asked March 16th 2010 by Daniel Hollis
  • activity
  • db
  • indicator
  • iphone
  • pre-packaged
  • preloading
  • tableview database

3 Answers

  • Hi Nick,

    I personally don't think that is too much to ask of the devices processor, since most apps are V fast.

    Most of the people/clients look at their apps and see long tableviews with nice interfaces containing Images, labels, background etc, so in their mind that is a possible and fast thing to achieve, I hope that the Titanium Team look this as a "Possible future improvement" and not as a "Work around solution" like its already been suggested.

    They suggested to paginate (showing 10-20), which is a great suggestion, but I am sure that most of people here are developing for clients and the more "We cannot do this, but we can do this instead" the more we are pushing our clients away. That is my personal opinion.

    I will carry on doing tests, and try a few thing and I will report back.

    I managed to get the ActivityIndicator working, I had to add it to the window at the top of the JS code, then after I add my tableview to the window I would hide id.

    var win = Titanium.UI.currentWindow;
    win.barColor = '#cc00f0';
    var actInd = Titanium.UI.createActivityIndicator({
    actInd.font = {fontFamily:'Helvetica Neue', fontSize:15,fontWeight:'bold'};
    actInd.color = '#000';
    actInd.message = 'Loading...';
    actInd.width = 210;
    // etc
    // etc
    var tableview = Titanium.UI.createTableView();
    tableview.separatorStyle = Ti.UI.iPhone.TableViewSeparatorStyle.SINGLE_LINE;
    tableview.separatorColor = "red";
    //THEN I ADDED TO THE WINDOW AND executed the hiding of the indicator.
    — answered March 16th 2010 by Daniel Hollis
  • Have you tried it without the 'animationStyle' setting when you do the 'setData'?

    Depending on the use case for the app and data, I would also suggest using pagination for large datasets. It might not be what you want though.

    — answered March 16th 2010 by Kosso
  • I may be wrong, but I think you are asking a lot of the devices processor.

    You should really think about paging the results.

    As far as showing an activityIndicator, add it before you start looping through your array, and hide it as the first call outside the loop. (or after you add the tableView to your window.

    — answered March 16th 2010 by Nick Lloyd
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.