Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8632] iOS: The display of the picker is not the same as its value

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionWon't Do
Resolution Date2020-01-10T18:03:46.000+0000
Affected Version/sRelease 1.8.0.1
Fix Version/sn/a
ComponentsiOS
Labelsapi
ReporterFederico Casali
AssigneeUnknown
Created2012-01-06T09:55:42.000+0000
Updated2020-01-10T18:03:46.000+0000

Description

Problem description

Information displayed in the Pciker ([Titanium.UI.Picker](http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.Picker-object)) it's not the same as its value

Steps to reproduce and code sample

* Run the code below * Click on the "begin" cell * Select a date and select a time 8:15 p.m. * Click on the "submit" button * Click on the "end" cell * The value of the picker is the date / time selected previously. However, the display shows a different time picker (8:45 p.m.)
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');

// create tab group
var tabGroup = Titanium.UI.createTabGroup();

//
// create base UI tab and root window
//
var win1 = Titanium.UI.createWindow({
	title : 'Tab 1',
	backgroundColor : '#fff'
});
var tab1 = Titanium.UI.createTab({
	icon : 'KS_nav_views.png',
	title : 'Tab 1',
	window : win1
});

var begining_date = null;
var ending_date = null;

var begining_date_row = Ti.UI.createTableViewRow({className:'begining_date_row', title:"begin", hasChild:true });
var ending_date_row = Ti.UI.createTableViewRow({className:'ending_date_row', title:"end", hasChild:true});

var begining_date_value = Ti.UI.createLabel({right:10,height:'auto',width:'auto',text:'',font:{fontSize:3}});
begining_date_row.add(begining_date_value);
var ending_date_value = Ti.UI.createLabel({right:10,height:'auto',width:'auto',text:'',font:{fontSize:3}});
ending_date_row.add(ending_date_value);

var data = [];
data[0] = Ti.UI.createTableViewSection();
data[0].add(begining_date_row);
data[0].add(ending_date_row);

		
var tableview = Ti.UI.createTableView({
	data:data,
	style: Titanium.UI.iPhone.TableViewStyle.GROUPED,
});
	
win1.add(tableview);



function open_window_begining_date(title, url, begining_date) {
	var win = Ti.UI.createWindow({
		title : title,
		url : url,
		begining_date : begining_date
	});

	tab1.open(win, {
		animated : true
	});
}


tableview.addEventListener('click',  function(e) {
	if(e.index == 0) {
		open_window_begining_date("Begin", './begining_date.js', begining_date);
	} else if(e.index == 1) {
		open_window_begining_date("End", './ending_date.js', begining_date);
	}
});


Ti.App.addEventListener('update_begining_date', function(d) {
	var begining_date_tmp = new Date();
	begining_date_tmp.setTime(d.time);
    begining_date = begining_date_tmp;
	begining_date_value.text = begining_date_tmp;
	tableview.setData(tableview.data);
});

Ti.App.addEventListener('update_ending_date', function(d) {
	var ending_date_tmp = new Date();
	ending_date_tmp.setTime(d.time);
    ending_date = ending_date_tmp;
	ending_date_value.text = ending_date_tmp;
	tableview.setData(tableview.data);
});

tabGroup.addTab(tab1);

// open tab group
tabGroup.open();

var current_window = Titanium.UI.currentWindow;

function create_picker(new_date) {
	date_picker = Ti.UI.createPicker({
		top : 70,
		type : Titanium.UI.PICKER_TYPE_DATE_AND_TIME,
		useSpinner : true,
		minuteInterval : 15,
		value : new_date
	});

	Titanium.API.info("Valeur of picker : " + current_date);

	current_window.add(date_picker);
	submit_button = Ti.UI.createButton({
		height : 35,
		width : 300,
		bottom : 10,
		title : 'submit'
	});

	current_window.setRightNavButton(submit_button);	
}


var current_date = Titanium.UI.currentWindow.begining_date;

create_picker(current_date);

submit_button.addEventListener('click', function() {
	
	Ti.App.fireEvent('update_begining_date',
	{
		time:current_date.getTime()
	});
	
	Ti.UI.currentWindow.close();
});


date_picker.addEventListener('change', function(e) {
		
	current_date = e.value;
	Titanium.API.info("Value of picker (on change) : " + e.value);
});

var current_window = Titanium.UI.currentWindow;

function create_picker(new_date) {
	date_picker = Ti.UI.createPicker({
		top : 70,
		type : Titanium.UI.PICKER_TYPE_DATE_AND_TIME,
		useSpinner : true,
		minuteInterval : 15,
		value : new_date
	});

	Titanium.API.info("Valeur of picker : " + current_date);

	current_window.add(date_picker);
	submit_button = Ti.UI.createButton({
		height : 35,
		width : 300,
		bottom : 10,
		title : 'submit'
	});

	current_window.setRightNavButton(submit_button);	
}


var current_date = new Date();

if (Titanium.UI.currentWindow.begining_date != null) {
	current_date = Titanium.UI.currentWindow.begining_date;
}

create_picker(current_date);


submit_button.addEventListener('click', function() {
	
	Ti.App.fireEvent('update_ending_date',
	{
		time:current_date.getTime()
	});
	
	Ti.UI.currentWindow.close();
});


date_picker.addEventListener('change', function(e) {
		
	current_date = e.value;
	Titanium.API.info("Value of picker (on change) : " + e.value);
});

Comments

  1. Paul Dowsett 2012-01-06

    Anthony While your ticket is in a perfect format, and I thank you for that, the test case is very complex. In order to determine the cause of this issue, and prove that it is not a problem with your code, please read [Creating a Test Case](https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report#HowtoSubmitaBugReport-CreatingaTestCase), and remove all unnecessary code. Once you do this, I will be able to escalate it. Thanks
  2. Anthony 2012-01-06

    Paul, I can not do less for this test case (if the bug is not reproducible) ... I have already greatly reduced my code. Thanks
  3. Paul Dowsett 2012-01-06

    To reproduce the issue... Do you need a tabgroup? Do you need a tableview? Do you need to open new windows? If each of these, if you do, then this needs to be stated as part of the problem. If not, then please remove them from the test case. Thank you
  4. Anthony 2012-01-13

    Yes i need ... It's very important for me. Thanks
  5. Paul Dowsett 2012-01-15

    Anthony My apologies, that is not what I meant, although the [Creating a Test Case](https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report#HowtoSubmitaBugReport-CreatingaTestCase) guide explains it in full. In order to create a test case, remove the tabgroup, tableview and new windows one by one. If the problem still exists, then these elements are not needed, so please remove them from the code above. Also avoid using the window.url property. Then I can escalate this issue. Thanks
  6. Alan Hutton 2020-01-10

    This issue is out of date with our current supported SDK release (7.5.2.GA as of the date of closure), and out of date with mobile OS versions. If community members feel that the issue is still valid, please create a new ticket. Please reference this closed ticket number, include SDK used, comments, and code that demonstrates/reproduces the issue.

JSON Source