Titanium JIRA Archive
Appcelerator Community (AC)

[AC-202] Update label.text from slider in TableView block the slider

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2015-07-21T21:39:39.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsios, tableview, tablewviewrow, update
Reporternicolomonili
AssigneeRadamantis Torres-Lechuga
Created2015-07-08T08:11:41.000+0000
Updated2015-07-21T21:39:39.000+0000

Description

I have a *Tableview* with some *TablewViewRow* with a *Label* and a *Slider*. The slider has two events , *touchstart* and *touchend* to see the rounded value of the slider in the label. The problem is simple. With this configuration (code posted below , test on iphone) , the slider is locked and the movement is not fluid. I noticed that if I replace the label with a *Textarea* the problem not persist.
var win = Ti.UI.createWindow();

var table_object = Ti.UI.createTableView({
    separatorColor : 'transparent',
    width : 320,
    height : 300,
    backgroundColor : 'black'
});


var row = Ti.UI.createTableViewRow({
    backgroundColor : 'gray',
    height : 120,
});
row.timer = null;

var label = Ti.UI.createLabel({
    text : "0%",
    top : 5,
    color : 'red',
    font : {
        fontSize : 30,
        fontWeight : 'bold'
    },
    width : 100,
    textAlign : 'center'
});

/*var label = Ti.UI.createTextArea({
    value : "0%",
    top : 5,
    color : 'red',
    font : {
        fontSize : 30,
        fontWeight : 'bold'
    },
    width : 100,
    textAlign : 'center'
});*/

var slider = Ti.UI.createSlider({
    min : 0.0,
    max : 100.0,
    value : 10,
    width : 300,
    left : 10,
    bottom : 10
});


slider.addEventListener('touchstart', function(e) {
    row.timer = setInterval(function() {
        label.text = parseValue(slider.value, 5) + "%";
        //label.value = parseValue(slider.value, 5) + "%";
    }, 50);
});

slider.addEventListener('touchend', function(e) {
    clearInterval(row.timer);
    var newValue = parseValue(e.value, 5);
    label.text = newValue + "%";
    //label.value = newValue + "%";
});

function parseValue(value, value_to_round) {
    value /= value_to_round;
    value = Math.round(value);
    value *= value_to_round;
    return value;
};

row.add(slider,label);
table_object.data = [row];
win.add(table_object);

win.open();

Attachments

FileDateSize
iOS Simulator Screen Shot 08.lug.2015 10.08.48.png2015-07-08T08:11:05.000+000025835

Comments

  1. Motiur Rahman 2015-07-09

    Hello [~nicolomonili], At first add a view to the row then add slider and label to it like this code
       view.add(label);
       view.add(slider);
       row.add(view);
       table_object.data = [row];
       win.add(table_object);
       
    [Document](http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.TableViewRow-method-add) also says about it. Thanks.
  2. nicolomonili 2015-07-09

    Yeah this solve the problem ! In any case, the problem arose with the latest SDK

JSON Source