Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2012] iOS: Datepicker returns null value

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionCannot Reproduce
Resolution Date2012-03-14T13:41:37.000+0000
Affected Version/sRelease 1.5.0
Fix Version/sn/a
ComponentsiOS
Labelsparity
ReporterFernando
AssigneeStephen Tramer
Created2011-04-15T03:08:04.000+0000
Updated2012-03-14T13:41:37.000+0000

Description

I'm running:

Titanium SDK Version: 1.4.0
Iphone SDK Version: 3.2/4.0
Titanium Developer: 1.2.1

Unfortunately i cannot use this simple code to get the value of a datepicker:

var myDatePicker = Ti.UI.createPicker({
    type:Ti.UI.PICKER_TYPE_DATE_AND_TIME,
    top: 0
});

debug( myDatePicker.value ); // returns null

KitchenSink shows how to get the value with an event ( and it works! ), but not when you need it outside an datepicker's event.

Comments

  1. Ernesto 2011-04-15

    I've also seen this issue.

    The workaround is manually updating the picker's value inside an onChange callback:

       picker.addEventListener('change', function(e) { picker.value = e.value; });
       
  2. Stephen Tramer 2011-04-15

    Continuously get 'null' using the following sample code - maybe another Apple bug regarding the date picker? Wouldn't be the first time.

       var win = Ti.UI.createWindow({backgroundColor:'white'});
       var myDatePicker = Ti.UI.createPicker({
           type:Ti.UI.PICKER_TYPE_DATE_AND_TIME,
           top: 0
       });
       
       Ti.API.info('Pre-add value: '+myDatePicker.value);
       win.add(myDatePicker);
       Ti.API.info('Post-add value: '+myDatePicker.value);
       
       win.addEventListener('focus', function() {
           Ti.API.info('Focus value: '+myDatePicker.value);
       });
       win.addEventListener('open', function() {
           Ti.API.info('Open value: '+myDatePicker.value);
       });
       
       win.open();
       
       var timer = setTimeout(function() {
           Ti.API.info('Timer value: '+myDatePicker.value);
       }, 1000);
       
  3. Paul Dowsett 2011-12-25

    This issue does not occur for the following environment: * 1.8.0.1 (12/22/11 13:09 fbdc96f) * iOS 4.3.2 * iphone simulator
       Titanium.UI.setBackgroundColor('#000');
       
       var win1 = Ti.UI.createWindow({
       	backgroundColor:'white',
       	fullscreen:false,
       	exitOnClose:true
       });
       
       var minDate = new Date(2011,11,1);
       
       var maxDate = new Date(2012,11,31);
       
       var value = new Date();
       
       var picker = Ti.UI.createPicker({
       	locale:'fr',
       	type:Ti.UI.PICKER_TYPE_DATE_AND_TIME,
       	minDate:minDate,
       	maxDate:maxDate,
       	value:value
       });
       picker.setLocale('fr');
       Ti.API.info('The current picker value is: ' + picker.value)
       win1.add(picker);
       
       win1.open();
       
       [INFO] One moment, building ...
       [INFO] Titanium SDK version: 1.8.0.1 (12/22/11 13:09 fbdc96f)
       [INFO] iPhone Device family: universal
       [INFO] iPhone SDK version: 4.3
       [INFO] iPhone simulated device: iphone
       [INFO] Launching application in Simulator
       [INFO] Launched application in Simulator (0.89 seconds)
       [INFO] Found 4.3.2 patch installed
       [INFO] Application started
       [INFO] testing11/1.0 (1.8.0.1.fbdc96f)
       [INFO] Application started
       [INFO] testing11/1.0 (1.8.0.1.fbdc96f)
       [INFO] The current picker value is: Mon Dec 26 2011 02:57:36 GMT+0000 (GMT)
       
  4. Paul Dowsett 2011-12-25

    Steve Please would you take a look at my last comment? Can this ticket be closed now? Thanks
  5. Stephen Tramer 2011-12-27

    Cannot reproduce in 1.9.0.d9bac09.
  6. Natalie Huynh 2012-01-12

    Tested with 1.9.0.v20120112104633
  7. Michael Pettiford 2012-02-01

    Reopening/closing to add/remove labels

JSON Source