Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10146] iOS: setSelectedRow on picker not working if window not open

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2012-08-14T10:41:06.000+0000
Affected Version/sRelease 2.1.0, Release 1.8.3
Fix Version/sSprint 2012-16 API, Release 2.1.2, Release 3.0.0
ComponentsiOS
Labelsapi, module_picker, parity, qe-testadded
ReporterAmuktha Akkinepally
AssigneeVishal Duggal
Created2012-07-25T16:10:33.000+0000
Updated2012-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();

STEPS TO REPRODUCE:

1. Load the above code into app.js 2. Run the project on iPhone simulator.

Comments

  1. Vishal Duggal 2012-07-27

    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).
  2. Vishal Duggal 2012-08-02

    Pull pending https://github.com/appcelerator/titanium_mobile/pull/2671
  3. Anshu Mittal 2012-08-09

    Reopening to update labels
  4. Sabil Rahim 2012-08-14

    Reopening to update fixVersion label 2.1.2

JSON Source