Skip to content

Instantly share code, notes, and snippets.

@minhnc
Created March 7, 2012 04:18
Show Gist options
  • Save minhnc/1990904 to your computer and use it in GitHub Desktop.
Save minhnc/1990904 to your computer and use it in GitHub Desktop.
Picker: Year & Month Only
/**
* yearRange: {min: 2000, max: 2012},
* monthRange: {min:1, max: 12}
*/
function monthYearPicker(yearRange, monthRange) {
var picker = Ti.UI.createPicker();
var yCol = Ti.UI.createPickerColumn();
for(var i = yearRange.min; i <= yearRange.max; i++) {
yCol.addRow(Ti.UI.createPickerRow({
title : i.toString()
}));
}
var mCol = Ti.UI.createPickerColumn();
for(var i = monthRange.min; i <= monthRange.max; i++) {
mCol.addRow(Ti.UI.createPickerRow({
title : i.toString()
}));
}
picker.add([yCol, mCol]);
return picker;
}
var win = Ti.UI.createWindow({backgroundColor: 'white'});
var picker = monthYearPicker({min: 2000, max: 2012}, {min: 1, max: 12});
picker.selectionIndicator = true;
win.add(picker);
win.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment