[TIMOB-10146] iOS: setSelectedRow on picker not working if window not open
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-08-14T10:41:06.000+0000 |
Affected Version/s | Release 2.1.0, Release 1.8.3 |
Fix Version/s | Sprint 2012-16 API, Release 2.1.2, Release 3.0.0 |
Components | iOS |
Labels | api, module_picker, parity, qe-testadded |
Reporter | Amuktha Akkinepally |
Assignee | Vishal Duggal |
Created | 2012-07-25T16:10:33.000+0000 |
Updated | 2012-08-14T17:38:37.000+0000 |
Description
By default 'Answer 5' should be selected on starting the app but it selects "Answer 0" on iOS. This code works fine on Android but not on iOS.
var win = Ti.UI.createWindow({
layout: 'vertical'
});
var picker = Ti.UI.createPicker({
type: Ti.UI.PICKER_TYPE_PLAIN,
selectionIndicator: true
});
var data = [];
var answerLoop = 0;
// add answers
for (answerLoop = 0; answerLoop < 11; answerLoop++) {
data.push(Ti.UI.createPickerRow({
title: 'Answer ' + answerLoop,
custom_item: answerLoop
}));
}
picker.add(data);
// THIS IS WHERE THE BUG IS
// This should selected the value 'Answer 5' but as you can see, Answer 1 is selected at startup
picker.setSelectedRow(0, 5, true);
var selectedButton = Ti.UI.createButton({
title: 'Select Answer 6',
width: 300,
height: 'auto'
});
selectedButton.addEventListener('click', function(e) {
picker.setSelectedRow(0, 6, true);
});
win.add(picker);
win.add(selectedButton);
win.open();
It is documented that this method should be called after the picker is rendered (in the example above in the open event handler of the window). However we will investigate if there is a way to fix it (we did this for map annotations).
Pull pending https://github.com/appcelerator/titanium_mobile/pull/2671
Reopening to update labels
Reopening to update fixVersion label 2.1.2