danielhanold / danielhanold.pickerwidget

Titanium widget that implements single column, date, and age-range pickers for iOS and Android
39 stars 13 forks source link

[UIPickerView setDatePickerMode:]: unrecognized selector sent to instance 0x7fb0ef642210"; #18

Open junerockwell opened 7 years ago

junerockwell commented 7 years ago

Using:

The code below:

$.picker.blur();
// Date Picker example.
// Set minimum date to 1900.
var minDate = new Date(new Date().setYear(1900));
// Set minimum date to today
var maxDate = new Date();

// Will load the last value
var _pickerValue = $.picker.getValue();
console.log('[*] Current Birth Date.');
console.log(_pickerValue);
var defaultValue = (_pickerValue) ? moment(_pickerValue, 'M/D/YYYY').toDate() : maxDate;
var maxSelectedDate = new Date();
var overlay = Alloy.createWidget('danielhanold.pickerWidget', {
    id: 'myDatePicker',
    outerView: $.mainWindow,
    hideNavBar: false,
    type: 'date-picker',
    pickerParams: {
      minDate: minDate,
      maxDate: maxDate,
      value: defaultValue,
      maxSelectedDate: maxSelectedDate,
      maxSelectedDateErrorMessage: 'The Person must be Born First!'
    },
    onDone: function(e) {
      var _date = (e.data && e.data.unixMilliseconds) ? e.data.unixMilliseconds : null;
      if (!_date) {
        $.picker.setValue('');
        return;
      }
      picker_date = moment(_date).format('l');
      $.picker.setValue(picker_date);
    },
  });

simulator screen shot feb 2 2017 3 42 43 pm

eliegkassouf commented 7 years ago

I am also running into this issue now. Any updates?

Thanks,

maronaquillo commented 7 years ago

You must set the picker type on creation. I added the type on the <Picker> in pickerView.xml. I haven't tested this one on android but it works on iOS.

<Picker id="picker" type="Ti.UI.PICKER_TYPE_DATE" />