[AC-202] Update label.text from slider in TableView block the slider
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2015-07-21T21:39:39.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | n/a |
Labels | ios, tableview, tablewviewrow, update |
Reporter | nicolomonili |
Assignee | Radamantis Torres-Lechuga |
Created | 2015-07-08T08:11:41.000+0000 |
Updated | 2015-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
File | Date | Size |
---|---|---|
iOS Simulator Screen Shot 08.lug.2015 10.08.48.png | 2015-07-08T08:11:05.000+0000 | 25835 |
Hello [~nicolomonili], At first add a view to the row then add slider and label to it like this code
[Document](http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.TableViewRow-method-add) also says about it. Thanks.
Yeah this solve the problem ! In any case, the problem arose with the latest SDK