Progress bar strange behaviour

You must Login before you can answer or comment on any questions.

Hi,

I'm using titanium studio 2.1.2. I noticed a strange behaviour on iphone (works fine on android) that I cannot explain. I have a progressbar that reads its value from a database. Whatever the value, the progressbar is always full. Then I programatically change the value and the progress bar displays fine. But when I close the view and reopen it (forcing to read the value in the DB), the progress bar is once more full. I precise that the value from the DB is correct as well as my min and max (and also as I said it works on android).

Anyone who had a similar issue and found the problem? Tks.

— asked 9 months ago by Francois Mouchati
2 Comments
  • please please please provide some code... we cannot read your mind and/or visualize what you code looks like to try and provide a solution

    http://developer.appcelerator.com/question/ask

    — commented 9 months ago by Aaron Saunders

  • Needless to say but have you tried using debugger or log statements to see what is the initial value that the code is setting for the progress bar. You may be seeing something in DB but you know 'sometimes' there are bugs in the code that can alter the value of a variable..

    — commented 9 months ago by Birender Saini

2 Answers

Accepted Answer

Had similar problems with progress bar. Now I always set max to 1 and value a float between 0.0 and 1.0, then it works also on launch.

So here is a bit of the code. I create the progress bar as below. Note that I also have a label that use the same value as the progress bar. The label is fine while the progress bar appears as full.

var maxPics=db.getMaxPicForLevel(i);
var foundPic=db.getNumFoundPicsForLevel(i);
var levelProgress = Titanium.UI.createProgressBar({
    width:'70%',left:'15%',bottom:'15%',
    min:0,
    max:maxPics,
    value:foundPic,
    color:'#fff',
    style:Titanium.UI.iPhone.ProgressBarStyle.PLAIN
});
var levelScore =  Titanium.UI.createLabel({
    text:foundPic+'/'+maxPics,
    textAlign:'right',right:'15%',top:0
});
In another view, I update the progress bar and then it appears fine.
for (var i =0 ; i < rows.length; i++) {
    var maxPics=db.getMaxPicForLevel(i+1);
    var foundPic=db.getNumFoundPicsForLevel(i+1);
    rows[i].children[2].value=foundPic;//progress bar
    rows[i].children[3].text=foundPic+'/'+maxPics;//level score
    rows[i].hasChild=!locked;
    (locked)?rows[i].children[0].image='/images/cross.png':rows[i].children[0].image='images/checked.png';
    locked=foundPic<levelView.lock_mod*maxPics;
}
Once again I only experience that behaviour on iPhone; it works as expected on android. Tks fo any help!

Your Answer

This question has been locked and cannot accept new answers.